博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
disable the touchpad by shortcut on the ubuntu
阅读量:4040 次
发布时间:2019-05-24

本文共 2898 字,大约阅读时间需要 9 分钟。

Disable touchpad using keyboard shortcut

Working on a laptop can be extremely annoying when you accidentally hit the touchpad with your fingers. Here’s an easy fix to disable/enable the touchpad using a keyboard shortcut (like Ctrl - Alt - M).
Step 1 Find the xinput device id of your touchpad
This is how I found mine.
fazle@thinkpad:~$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=11 [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)]
↳ Truevision HD id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
↳ WMI hotkeys id=12 [slave keyboard (3)]
fazle@thinkpad:~$
From the list I can easily see the id I am looking for is 11. If you are not sure, try this
fazle@thinkpad:~$ xinput test 11
motion a[1]=2919
motion a[1]=2916
motion a[1]=2914
motion a[1]=2913
motion a[1]=2911
motion a[0]=2153 a[1]=2900
motion a[0]=2146 a[1]=2894
motion a[1]=2891
motion a[0]=2145 a[1]=2885
motion a[0]=2144 a[1]=2876
motion a[0]=2142
motion a[0]=2141
motion a[0]=2140 a[1]=2874
motion a[1]=2867
motion a[0]=2140
motion a[0]=2137 a[1]=2860
motion a[1]=2864
motion a[0]=2160 a[1]=2889
Run the command and swipe your finger on the touchpad. If you have the correct id, you would get those numbers. So we found the id for the touchpad which is 11 for my laptop.
Step 2 Create the bash script
Save the file somewhere in your path. Like /usr/local/bin/disable-touchpad.sh
Also, don’t forget to change the TOUCHPADID

#!/bin/bash## Purpose: Toggle synaptic touchpad on/off# Author: Fazle Arefin# Reference: http://ubuntuforums.org/showthread.php?t=1536305#TOUCHPADID=11    # change this idSYNSTATE=$(xinput list-props "$TOUCHPADID" | grep "Device Enabled" | grep -Eo '.$')if [ $SYNSTATE = 0 ]; then     xinput set-prop "$TOUCHPADID" "Device Enabled" 1else     xinput set-prop "$TOUCHPADID" "Device Enabled" 0fi

Make sure it is executable by you

chmod 755 /usr/local/bin/disable-touchpad.sh
Step 3 Setup a keyboard shortcut
Go to your Settings > Keyboard > Shortcuts using the GUI. In custom shortcuts point to /usr/local/bin/disable-touchpad.sh and setup the keyboard shortcut. I use Ctrl- Alt - Shift-T to enable/disable the touchpad.

update on 14, Oct, 18

Just found the touchpadid changes dynamically every time I start up my computer, so I cannot set it as a fixed value, instead, I found it out by myself.

TOUCHPADID=$(xinput | grep "Touchpad" | grep -Po 'id=\K[0-9]+')SYNSTATE=$(xinput list-props "$TOUCHPADID" | grep "Device Enabled" | grep -Eo '.$')if [ $SYNSTATE = 0 ]; then     xinput set-prop "$TOUCHPADID" "Device Enabled" 1else     xinput set-prop "$TOUCHPADID" "Device Enabled" 0fi

转载地址:http://gaxdi.baihongyu.com/

你可能感兴趣的文章
kprobe学习
查看>>
慢慢欣赏linux phy驱动初始化2
查看>>
慢慢欣赏linux CPU占用率学习
查看>>
2020年终总结
查看>>
Homebrew指令集
查看>>
React Native(一):搭建开发环境、出Hello World
查看>>
React Native(二):属性、状态
查看>>
JSX使用总结
查看>>
React Native(四):布局(使用Flexbox)
查看>>
React Native(七):Android双击Back键退出应用
查看>>
Android自定义apk名称、版本号自增
查看>>
adb command not found
查看>>
Xcode 启动页面禁用和显示
查看>>
【剑指offer】q50:树中结点的最近祖先
查看>>
二叉树的非递归遍历
查看>>
【leetcode】Reorder List (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Word Break(python)
查看>>
【leetcode】Candy(python)
查看>>