Min*_*gen 2 touchpad scripts shortcut-keys
我有一台新的戴尔笔记本电脑,我想创建一个键盘快捷键来禁用和启用触摸板。我该怎么做呢?
部分归功于这篇文章(启用/禁用触摸板)
创建一个新目录/home/USER/bin,然后使用gedit /home/USER/bin/toggle-touchpad. 注意:将USER替换为您的用户 ID。将这些行复制并粘贴到您的编辑器中:
#!/bin/bash
# NAME: toggle-touchpad
# PATH: /home/$USER/bin
# DESC: Update pulseaudio output device when HDMI TV plugged / unplugged
# CALL: called from Keyboard Shortcut `Super`+`T`
# DATE: Created Dec 23, 2016.
# NOTE: Written for AU question: http://askubuntu.com/questions/863746/keyboard-shortcut-to-disable-the-laptop-touchpad/863750?noredirect=1#comment1333958_863750
# Use device number matching touchpad, in this case 14
if [[ $(xinput list 14 | grep -Ec "disabled") -eq 1 ]]; then
xinput enable 14
DISPLAY=:0 notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/user-available.png "Touchpad enabled"
else
xinput disable 14
DISPLAY=:0 notify-send --urgency=critical --icon=/usr/share/icons/gnome/256x256/status/user-busy.png "Touchpad disabled"
fi
exit 0
Run Code Online (Sandbox Code Playgroud)
保存文件并退出编辑器。现在使用chmod +x /home/USER/bin/toggle-touchpad
打开System Settings?Keyboard? Shortcuts? Custom Shortcuts?+
出现此屏幕:
像这样填写自定义快捷方式字段:
Toggle Touchpad/home/USER/bin/toggle-touchpad点击Apply按钮保存。
新条目显示为Disabled状态。右键单击已禁用并使用Super+ Z(或任何其他未使用的快捷键组合)。我想使用Super+T但它已经分配给Nautilus Trashcan。
默认设备编号设置为 14。要了解您的设备编号,请使用以下命令:
???????????????????????????????????????????????????????????????????????????????
USER@host:~/bin$ xinput
? Virtual core pointer id=2 [master pointer (3)]
? ? Virtual core XTEST pointer id=4 [slave pointer (2)]
? ? Logitech Performance MX id=10 [slave pointer (2)]
? ? Logitech K800 id=11 [slave pointer (2)]
? ? AlpsPS/2 ALPS GlidePoint id=14 [slave pointer (2)]
? Virtual core keyboard id=3 [master keyboard (2)]
? Virtual core XTEST keyboard id=5 [slave keyboard (3)]
? Power Button id=6 [slave keyboard (3)]
? Video Bus id=7 [slave keyboard (3)]
? Power Button id=8 [slave keyboard (3)]
? Sleep Button id=9 [slave keyboard (3)]
? Laptop_Integrated_Webcam_HD id=12 [slave keyboard (3)]
? Dell WMI hotkeys id=15 [slave keyboard (3)]
? AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
???????????????????????????????????????????????????????????????????????????????
USER@host:~/bin$
Run Code Online (Sandbox Code Playgroud)
您可以选择任何您喜欢的设备,即触摸板 = 14、网络摄像头 = 12 等。
您使用哪个设备编号,只需打开您的/home/USER/bin/toggle-touchpad脚本并替换14为该设备编号。
当显示“启用触摸板”/“禁用触摸板”通知气泡时,文本左侧会显示一个图标。使用股票图标,/usr/share/icons/gnome/256x256/status/但您可以更改它们。
要启用触摸板,会显示:
要禁用触摸板,会显示: