Keyboard shortcut to disable touchpad
As I wrote a few hours ago it would be nice to be able to have a keyboard shortcut to enable/disable the touchpad. So when I started eat a chocolate cake I decided to fix the problem for Ubuntu and MSI S271. It should work in most GNOME-based Linux distributions and for most touchpads.
First I wrote a script to toggle the touchpad (download here):
#!/bin/bash
if lsmod | grep "^psmouse " > /dev/null ; then
/usr/bin/sudo /sbin/rmmod psmouse ;
else
/usr/bin/sudo /sbin/modprobe psmouse ;
fi
No rocket science here. Put the script some where on your harddrive, like /usr/local/bin. Add the following line in the end of your /etc/sudoers file:
ALL ALL=(ALL)NOPASSWD: /sbin/rmmod psmouse, /sbin/modprobe psmouse
This gives all users the right to enable and disable the touchpad.
Register your the script as a keybinding command in gconf:
gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_1 "/usr/local/bin/toggle-tp.sh"
Register in the same way what shortcut key to launch the command:
gconftool-2 -t str --set /apps/metacity/global_keybindings/run_command_1 "0xb2"
I selected the webbrowser launcher-key, which have 0xb2 as keycode, to toggle my touchpad. You can find examples of other keycodes here.
First I wrote a script to toggle the touchpad (download here):
#!/bin/bash
if lsmod | grep "^psmouse " > /dev/null ; then
/usr/bin/sudo /sbin/rmmod psmouse ;
else
/usr/bin/sudo /sbin/modprobe psmouse ;
fi
No rocket science here. Put the script some where on your harddrive, like /usr/local/bin. Add the following line in the end of your /etc/sudoers file:
ALL ALL=(ALL)NOPASSWD: /sbin/rmmod psmouse, /sbin/modprobe psmouse
This gives all users the right to enable and disable the touchpad.
Register your the script as a keybinding command in gconf:
gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_1 "/usr/local/bin/toggle-tp.sh"
Register in the same way what shortcut key to launch the command:
gconftool-2 -t str --set /apps/metacity/global_keybindings/run_command_1 "0xb2"
I selected the webbrowser launcher-key, which have 0xb2 as keycode, to toggle my touchpad. You can find examples of other keycodes here.
Comments
Have a nice day
-- Basim
From the System menu, choose Preferences and then Keyboard Shortcuts.
Scroll to the bottom, and click on the Add button at the bottom.
In the new window, enter the name:
Toggle touchpad
and the command:
/usr/bin/gconftool --toggle /desktop/gnome/peripherals/mouse/touchpad_enabled
Then you can assign whatever keyboard shortcut you like to it. I use ctrl-alt-t.
It works like a charm now, BTW :D