有没有办法通过命令行(无需软件)设置键盘快捷键,使用相同的快捷键组合在两个命令之间切换。实际上,我想在使用鼠标时切换鼠标垫。
答案1
是的,这是可能的。首先,您需要识别您的触摸板。运行xinput list
(您可能必须先安装xinput
)sudo apt install xinput
。在我的系统上,显示:
$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ TPPS/2 IBM TrackPoint id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=12 [slave pointer (2)]
⎜ ↳ Logitech M325 id=10 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=15 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Integrated Camera id=13 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Logitech USB Receiver id=18 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=14 [slave keyboard (3)]
↳ Video Bus id=8 [slave keyboard (3)]
↳ ThinkPad Extra Buttons id=17 [slave keyboard (3)]
因此,我的触摸板名为SynPS/2 Synaptics TouchPad
。找出你的触摸板名称,然后相应地修改此脚本:
#!/bin/bash
## Change this value to whatever your touchpad is called
touchpad='SynPS/2 Synaptics TouchPad'
status=$(xinput list-props "$touchpad" | grep "Device Enabled" | gawk '{print $NF}');
if (( $status==1 )); then
xinput -set-int-prop "$touchpad" "Device Enabled" 8 0
else
xinput -set-int-prop "$touchpad" "Device Enabled" 8 1
fi
将该脚本另存为,~/bin/toggle_touchpad.sh
然后使用桌面环境的 GUI 为其分配快捷方式。快捷方式现在将运行脚本并根据需要切换触摸板。