我喜歡使用滑鼠中鍵模擬,因為我的滑鼠中鍵是滾輪,需要很大的壓力才能記錄點擊。這很快就會造成身體上的疼痛。
我發現同時單擊滑鼠左鍵和右鍵會更容易。而且我一直在使用這個功能。
我有一個腳本~/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
在腳本開頭新增 a 。
我還嘗試將腳本的內容添加到~/.profile
.
這些事情都沒有奏效。這已經困擾我很多年了!
感謝您的瀏覽:-)
編輯
- 也嘗試過
Exec=/bin/bash /home/david/.scripts/mouse.sh
。謝謝@普拉塔普 - 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
。