Wednesday, June 13, 2012

Ubuntu 12.04: Disabling touchpad

It seems that most laptops with a hardware button to toggle touch-pad on/off work just fine. However, the soft-touch keys as it is on "HP-dv7-6190ed" seem not to work.

I found this script on the net.
(don't know where, so I repeat the post. thanks to the original coder)

1. You need to have python (pref. 2.7x) installed on your system.
Open "Ubuntu Software Center" and search for "python"
it will be listed as: "interactive high-level object-oriented language ( default version)"



2. Open terminal screen and type:

gksudo gedit /usr/local/bin/toggle_touchpad.py

3. copy/paste the following code:


#!/usr/bin/python2.7
import subprocess

def touchpad_currently_off():
  all_states = subprocess.check_output(['synclient']).split('\n')
  off_state = next((s for s in all_states if 'touchpadoff' in s.lower()), None)
  return '1' in off_state

def main():
  if touchpad_currently_off():
    subprocess.check_call(['synclient', 'touchpadoff=0'])
  else:
    subprocess.check_call(['synclient', 'touchpadoff=1'])

if __name__ == '__main__':
  main()


4. Save and exit editor.
5. At the command-line, change permissions for the script with:

sudo chmod +x /usr/local/bin/toggle_touchpad.py

6. Add script to a short-cut on the keyboard (
I choose Ctrl+F1, but you can use whatever non-conflicting combination you like)
open keyboard manager and add a custom short-cut. (see image below)



 7. Log off or reboot to enable script.

 Now you should be able to toggle your touch-pad on/off by Ctrl+F1.

No comments:

Post a Comment

Please be courteous, even if you do not share the same view.