如何在 USB 鼠标连接上禁用笔记本的触摸板(最后一个更慢)?

Esa*_*amo 8 mouse touchpad usb 14.04

不是function key/fn为:(。

有任何想法吗?也许有设置或命令?


其他科目没有帮助:

  • gpointing-device-settings (自动禁用设置被取消);
  • kde-config-touchpad (不能单独安装);
  • 不知道怎么用udevd

小智 9

解决方案 - 自动

感谢 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"
Run Code Online (Sandbox Code Playgroud)

例子:

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"
Run Code Online (Sandbox Code Playgroud)

接下来将您的脚本放置在您想要的任何位置。我把它放在 ~/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
Run Code Online (Sandbox Code Playgroud)

记得添加执行权限:

chmod +x touchpad_switcher.sh

现在只需重新启动!(仅仅重新启动 udev 似乎不起作用......)


其他一些有用的东西:

关于udev 规则的一些信息

来自 ArchLinux 的示例

类似问题


Esa*_*amo 5

解决方案 - 不是自动的

下面的脚本在执行时将禁用触摸板,如果连接了任何鼠标并显示通知。

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
Run Code Online (Sandbox Code Playgroud)

还添加了一个相反的情况,尽管在我的情况下,无论如何触摸板都会在鼠标断开连接时启用。我已将脚本保存在一个文件中,并Unity Launcher Terminal在每次插入鼠标后从部分运行它。


先进的

  1. 更多的老鼠?

    mouse通过扩展"mouse"片段中的值,基于xinput设备列表的名称来澄清哪个应该停用触摸板。

  2. 害怕的老鼠从边缘跑到边缘?

    我不得不为鼠标运行额外的命令 - 减少,cursor acceleration因为它在每个连接上都被疯狂地设置为 10。实际上过了一段时间我制作了自动检测脚本(它获取鼠标 ID 和它的速度道具;不知道性能cut)...

    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
    
    Run Code Online (Sandbox Code Playgroud)

今天在上面学到了很多东西:D。


专业人士?

  1. 知道如何使其自动化会很有用。

  2. 也很好奇为什么不保存鼠标配置(2.)。