如何在USB鼠标连接上禁用笔记本的触摸板(并且最后一个慢)?
我没有 function key
/ fn :(。
有任何想法吗? 也许有设置或命令?
其他科目没有帮助:
-
gpointing-device-settings
(自动禁用设置未被取消); -
kde-config-touchpad
(不能单独安装); - 不知道如何使用
udevd
。
解决方案 – 自动
感谢Esamo和他的工作。
要在启动时添加用于连接鼠标的AUTO触发器:
创建文件: /etc/udev/rules.d/10-local.rules
填写此内容:(用您的用户名替换$ USER)
ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/$USER/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/$USER/scripts/touchpad_switcher.sh false" ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/$USER/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/$USER/scripts/touchpad_switcher.sh true"
例:
ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/dawid/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/dawid/scripts/touchpad_switcher.sh false" ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/dawid/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/dawid/scripts/touchpad_switcher.sh true"
接下来将脚本放在任何位置。 我把它放在〜/ scripts中
touchpad_switcher.sh
#!/bin/sh enabled=$1 touchpad_id=$(xinput | grep -i "touchpad" | cut -f2 | cut -d '=' -f2); if $enabled then xinput set-prop $touchpad_id "Device Enabled" 1 | notify-send "The touchpad is now enabled." "" else xinput set-prop $touchpad_id "Device Enabled" 0 | notify-send "Disabling the touchpad..." "" fi
记得添加执行权限:
chmod +x touchpad_switcher.sh
现在只需重启! (只是重新启动udev似乎不起作用……)
其他一些有用的东西:
有关udev规则的一些信息
ArchLinux的示例
模拟问题
解决方案 – 不是自动的
下面的脚本在执行时, 如果连接了任何鼠标并显示通知,将禁用触摸板 。
touchpad_id=$(xinput | grep -i "touchpad" | cut -f2 | cut -d '=' -f2); if xinput | grep -i "mouse" | grep -i "pointer" then xinput set-prop $touchpad_id "Device Enabled" 0 | notify-send "Disabling the touchpad..." "" else xinput set-prop $touchpad_id "Device Enabled" 1 | notify-send "The touchpad is now enabled." "" fi
还添加了相反的情况,尽管在我的情况下触摸板无论如何都会在鼠标断开时启用。 我已经将脚本保存在一个文件中,并在每次插入鼠标后从Unity Launcher
Terminal
部分运行它。
高级
-
更多老鼠?
通过扩展
"mouse"
片段中的值来明确哪个mouse
应该停用触摸板,该名称基于xinput
设备列表。 -
害怕的鼠标从边缘到边缘运行?
我不得不为鼠标运行额外的命令 – 减少
cursor acceleration
因为它在每个连接上疯狂地设置为10。 实际上过了一段时间我做了自动检测脚本(它得到了鼠标id和它的’速度支柱;关于cut
性能的dunno)……touchpad_id=$(xinput | grep -i "touchpad" | cut -f2 | cut -d '=' -f2); mouse_id=$(xinput | grep -i "mouse" | grep -i 'pointer' | cut -f2 | cut -d '=' -f2); mouse_prop=$(xinput list-props $mouse_id | grep -i "velocity" | cut -f2 | cut -d '(' -f2 | cut -d ')' -f1 ); if xinput | grep -i "mouse" | grep -i "pointer" then xinput set-prop $touchpad_id "Device Enabled" 0 | xinput set-prop $mouse_id $mouse_prop 3 | notify-send "Disabling the touchpad..." "" else xinput set-prop $touchpad_id "Device Enabled" 1 | notify-send "The touchpad is now enabled." "" fi
今天学到了很多东西:D。
有人专业吗?
-
了解如何使其自动化会很有用。
-
还好奇为什么不保存鼠标配置(2.)。
@David Drozd发布的内容在Ubuntu 16.04上对我不起作用。
似乎xinput
的技巧在udev
不起作用。 只有synclient TouchpadOff=[0|1]
有效。 ACTION="remove"
也不起作用。
添加ENV{REMOVE_CMD}="/bin/sh -c '/usr/bin/synclient TouchpadOff=0'"
时,我终于得到了它
完整的解决方案 :使用以下行创建文件/etc/udev/rules.d/10-local.rules
(用您的用户名替换$ USER)
ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/$USER/.Xauthority", ENV{REMOVE_CMD}="/bin/sh -c '/usr/bin/synclient TouchpadOff=0'", RUN+="/bin/sh -c '/usr/bin/synclient TouchpadOff=1' "