我喜欢使用鼠标中键模拟,因为我的鼠标中键是滚轮,需要很大的压力才能按下去。这很快就会让我感到疼痛。
我发现同时单击鼠标左键和右键要容易得多。而且我一直使用这个功能。
我有一个脚本~/scripts/mouse.sh
可以执行此操作:
#!/bin/bash
# Enable middle button emulation
# from https://askubuntu.com/a/201825/54278
if [[ -n ${DISPLAY} ]]; then
pointer1="MX Master"
id1=$(xinput | awk -F= "/$pointer1.*pointer/ {print \$2}" | cut -f1)
xinput set-prop "${id1}" "libinput Middle Emulation Enabled" 1
fi
这很有效,但每次重启时我都必须手动运行它。
我已经创建了~/.config/autostart/mouse.sh.desktop
。这些是内容:
[Desktop Entry]
Type=Application
Exec=/home/david/.scripts/mouse.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_AU]=Mouse
Name=Mouse
Comment[en_AU]=Middle button emulation
Comment=Middle button emulation
我的问题是我的脚本在登录时不执行任何操作。
在鼠标中键模拟工作之前,我仍然必须打开一个终端并运行我的脚本。
我尝试删除该if [[ -n ${DISPLAY} ]]; then
条件,也尝试sleep
在脚本开头添加一个。
我也尝试将我的脚本内容添加到~/.profile
。
这些方法都没用。这个问题困扰了我好几年!
感谢您的关注 :-)
編輯
- 也试过了
Exec=/bin/bash /home/david/.scripts/mouse.sh
。谢谢@PRATAP - Ubuntu 19.04,尽管它在最近的几个版本中也无法正常工作,包括 18.04
- 尝试删除 .desktop 文件并使用启动应用程序 GUI
- 尝试删除该
if [[ -n ${DISPLAY} ]]; then
条件 - 我灵光一闪,尝试使用
Exec=/usr/bin/xterm -e /home/david/.scripts/mouse.sh
- 也没有成功
答案1
对我有用的是下面的脚本
/home/user/mouse.sh
#!/bin/bash
pointer1="Logitech USB Receiver Mouse"
id1=$(xinput | awk -F= "/$pointer1.*pointer/ {print \$2}" | cut -f1)
xinput set-prop "${id1}" "libinput Middle Emulation Enabled" 1
一些输出xinput
$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech Touchpad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver Consumer Control id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver Mouse id=18 [slave pointer (2)]
/bin/bash /home/user/mouse.sh
并在启动应用程序偏好设置中添加命令。