用于切换(启用/禁用)笔记本电脑触摸板的键盘快捷键

我有一台新戴尔笔记本电脑,我想创建一个键盘快捷键来禁用和启用触摸板。 我该怎么做呢?

使用屏幕通知打开/关闭触摸板的脚本

此post的部分功劳( 启用/禁用触控板 )

创建切换触摸板脚本

创建一个新目录/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 

将切换触摸板脚本标记为可执行文件

保存文件并退出编辑器。 现在使用chmod +x /home/USER/bin/toggle-touchpad将文件标记为可执行文件

将切换触摸板脚本分配给键盘快捷键

打开System SettingsKeyboardShortcutsCustom Shortcuts+

出现此屏幕:

切换触控板

填写自定义快捷方式字段,如下所示:

  • Name = Toggle Touchpad
  • Command = /home/USER/bin/toggle-touchpad

单击“ 应用”按钮保存。

出现新条目状态为已禁用 。 右键单击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$ 

您可以选择任何您喜欢的设备,即触摸板= 14,网络摄像头= 12等。

您使用的是哪个设备编号,只需打开/home/USER/bin/toggle-touchpad脚本,然后将14替换为该设备编号。

修改切换触摸板脚本以使用不同的图标

当显示“触控板启用”/“触控板禁用”通知气泡时,文本左侧会显示一个图标。 股票图标使用/usr/share/icons/gnome/256x256/status/但您可以更改它们。

为了启用触摸板,显示:

用户可用

要禁用触摸板,请显示:

用户忙

一些计算机具有用于此目的的function键 。 例如,我的东芝有Fn F5

您可以通过标准Ubuntu中的设置 – 鼠标和触摸板轻松完成。 (带齿轮和扳手的图标)。

否则,你可以使用轻量级Ubuntu风格的终端命令来完成它

禁用:

 synclient touchpadoff=1 

启用:

 synclient touchpadoff=0 

您可以为这些命令创建别名,或者使用’touchpad-toggle alias’。

看到

 man synaptics 

更多细节。

  Option "TouchpadOff" "integer" Switch off the touchpad. Valid values are: 0 Touchpad is enabled 1 Touchpad is switched off (physical clicks still work) 2 Only tapping and scrolling is switched off When the touchpad is switched off, button events caused by a physical button press are still interpreted. On a ClickPad, this includes software-emulated middle and right buttons as defined by the SoftButtonAreas setting.