sm702 发表于 2018-5-6 14:08:47

Ubuntu12.04禁用触摸板的方法

  Ubuntu 12.04默认没有关闭触摸板,每次打字的时候,难免会碰到。而且每次禁用之后,重启又会失效。
  一、彻底禁用的方法。
  此方法需要修改/etc/modprobe.d/blacklist.conf文件:
  sudo gedit /etc/modprobe.d/blacklist.conf
  在文件最后加入以下语句,保存,重启即可:
  blacklist psmouse
  通过以上方法禁用触摸板之后,无法再重新启用触摸板,除非删除添加的语句,重启电脑。
  PS:
  其实这个方法是可以实现禁用/启用触摸板的。只要用rmmod/insmod命令删除/加载psmouse模块就行了
  psmouse模块所在目录可以用如下方法来寻找
  cd /lib/modules
  du -a |grep psmouse
  在我电脑上就显示
  116    ./3.2.0-29-generic/kernel/drivers/input/mouse/psmouse.ko
  也就是说psmouse模块在/lib/modules/3.2.0-29-generic/kernel/drivers/input/mouse/目录下
  这样
  sudo rmmod psmouse就禁用触摸板
  sudo insmod
  /lib/modules/3.2.0-29-generic/kernel/drivers/input/mouse/psmouse.ko就启用触摸板
  二、还有一个应用指示器(Indicator)可以很方便的禁用和启用触摸板,方法如下:
  安装Touchpad Indicator (触摸板开关)
  sudo add-apt-repository ppa:atareao/atareao
  sudo apt-get update
  sudo apt-get install touchpad-indicator
  安装完之后需要重启电脑。可以根据需要随时关闭、启用触摸板或者设置为插入鼠标后禁用触摸板。
  三、通过xinput可以来启用和禁用输入设备,以此来达到我需要的功能。
  查看设备列表
  通过xinput先查看一些都有哪些设备
  xinput #或xinput list
  显示结果如下
  ddd@ddd:~$ xinput list
  Virtual core pointer                        id=2   
  ↳ Virtual core XTEST pointer                  id=4   
  ↳ MLK rapoo 1800                              id=11   
  ↳ ETPS/2 Elantech Touchpad                  id=14   
  Virtual core keyboard                     id=3   
  ↳ Virtual core XTEST keyboard               id=5   
  ↳ Power Button                              id=6   
  ↳ Video Bus                                 id=7   
  ↳ Video Bus                                 id=8   
  ↳ Sleep Button                              id=9   
  ↳ MLK rapoo 1800                              id=10   
  ↳ Lenovo EasyCamera                           id=12   
  ↳ AT Translated Set 2 keyboard                id=13   

  ↳>  其中ETPS/2 Elantech Touchpad就是我笔记本的触摸板,其中id=14为设备的编号。这两者是等价的。
  查看设备属性
  xinput list-props 14
  xinput list-props 'ETPS/2 Elantech Touchpad'
  结果如下:(不全,只是为了显示一下大概有什么内容)
  ddd@ddd:~$ xinput list-props 'ETPS/2 Elantech Touchpad'
  Device 'ETPS/2 Elantech Touchpad':
  Device Enabled (132):    1
  Device Accel Profile (259):    1
  Device Accel Velocity Scaling (262):    12.500000
  Synaptics Edges (282):    56, 1352, 34, 606
  Synaptics Finger (283):    1, 1, 256
  Synaptics Tap Time (284):    180
  Synaptics Tap Move (285):    68

  Device Product>  Device Node (250):    "/dev/input/event7"
  其中有个属性Device Enabled表示设备的是禁用还是启用,1表示启用,0表示禁用。另外括号中的132也是表示Device Enabled,这两者是等价的。上面提到的设备名称和设备id也是等价的。
  禁用、启用触摸板
  用过set-porp来设置设备的属性。
  #禁用触摸板
  xinput set-prop 14 'Device Enabled' 0#通过设备编号+属性名禁用触摸板
  xinput set-prop 'ETPS/2 Elantech Touchpad' 'Device Enabled' 0 #通过设备名+属性名禁用触摸板
  #启用触摸板
  xinput set-prop 14 132 1 #通过设备编号+属性编号来设置
  xinput set-prop 'ETPS/2 Elantech Touchpad' 132 1 #通过设备名+属性编号启用
  刚才说了在我的电脑ETPS/2 Elantech Touchpad和14是等价的,Device Enabled和132是等价的,所以两者可以替代,于是敲命令的时候可以偷懒下。不过像这样看着比较直观这个命令到底是干什么。
  xinput set-prop 'ETPS/2 Elantech Touchpad' 'Device Enabled' 0
  通过脚本快速启用和禁用触摸板
  每次如果都敲命令也是比较麻烦的,通过脚本就很快的切换了。
  #!/bin/bash
  if [ $1 == 'on' ]
  then
  set-prop 'ETPS/2 Elantech Touchpad' 'Device Enabled' 1
  echo "触摸板开启成功!"
  elif [ $1 == 'off' ]
  then
  set-prop 'ETPS/2 Elantech Touchpad' 'Device Enabled' 0
  echo "触摸板关闭成功!"
  else
  echo "请输入参数:on/off"
  echo "开启触摸板:touchpadEnable on"
  echo "禁用触摸板:touchpadEnable off"
  fi
  通过禁用触摸板,确实给我解决了不少的麻烦。
  开机自动禁用触摸板
  但是这样在开机重启后又恢复了,对有些同学喜欢关机而不是休眠的同学确实还要改进,就是让开机的时候自动运行禁用触摸板的命令。
  在~/.config/autostart/下创建一个启动器xinput.desktop文件,内容如下

  Type=Application
  Exec=xinput set-prop 'ETPS/2 Elantech Touchpad' 'Device Enabled' 0
  Hidden=false
  NoDisplay=false
  X-GNOME-Autostart-enabled=true
  Name=touchpad enable
  Name=touchpad enable
  Comment=禁用触摸板
  Comment=禁用触摸板
  这样在开机的时候就能自动禁用触摸板了。
  不好的地方就是原来通过Fn+F8禁用触摸板时有灯亮的,现在不亮了,更好的方法应该是通过脚本模拟Fn+F8来禁用触摸板。
页: [1]
查看完整版本: Ubuntu12.04禁用触摸板的方法