A Linux-mint7 is installed on the notebook, which is a release based on Ubuntu9.04. A small problem persists after installation, that is, you cannot use the function key on the keyboard to close the touchpad. You can only set it on the graphic interface set by the mouse. If you want to switch between them, it is too troublesome. Two commands are used to enable and disable the touchpad: synclienttouchpadoff = 1 -- disable the touchpad command: synclienttouchpadoff = 0 -- enable the touchpad
A Linux-mint7 is installed on a notebook, a release based on Ubuntu 9.04. A small problem persists after installation, that is, you cannot use the function key on the keyboard to close the touchpad. You can only set it on the graphic interface set by the mouse. If you want to switch between them, it is too troublesome.
Two commands are used to enable or disable the touchpad.
Command: synclient touchpadoff = 1 -- close the touchpad
Command: synclient touchpadoff = 0 -- enable the touchpad
But you need to open the option SHMConfig first. Otherwise, an error will be reported when you run these two commands:
Can't access shared memery area. SHMconfig disabled?
To enable this option, you need to add a file:
Gksudo gedit/etc/hal/fdi/policy/shmconfig. fdi
Put the following content in the file:
On
You can bind two shortcut keys to the two commands, for example + F8 is enabled, + F9 is disabled, but this is inconvenient. It is best to switch between two states with a shortcut key. We need a script to do this.
Write a script file lockpad. py with the following content:
#! /Usr/bin/python
#-*-Coding: utf8 -*-
# This script is used to close or open the touchpad, And will switch between the two States during running.
# To make this script take effect, you must first set the System Option SHMConfig to yes.
# Vivian Wang
Import subprocess
StdReturn = subprocess. Popen (args = 'synclient-l', shell = True ,\
Stdout = subprocess. PIPE, stderr = subprocess. PIPE). communicate ()
If len (stdReturn) = 0:
Exit ()
Vl = stdReturn [0]. split ()
I = vl. index ('touchpadoff ')
If I <0:
Import gtk
Import pygtk
Md = gtk. MessageDialog (None ,\
Gtk. DIALOG_DESTROY_WITH_PARENT, gtk. MESSAGE_INFO ,\
Gtk. BUTTONS_ OK, "SHMConfig shocould be enabled .")
Md. set_position (gtk. WIN_POS_CENTER)
Md. run ()
Md. destroy ()
Exit ()
Subprocess. Popen (args = 'synclient touchpadoff = '+ str (1-int (vl [I + 2]), shell = True)
This script first reads whether the current status of the touchpad is enabled or disabled, and then calls the corresponding commands to open or close it.
Use
Chmod + x lockpad. py
Set it to executable.
To bind a shortcut key, select commands in CompizConfig and add a command:
/Home/vivian/lockpad. py
Point to the script file above.
Then, on the Key Bindings page, set the BIND Key value corresponding to this command + F9.
In this way + F9 switches between enable and disable the touchpad.
After practice, the command is always valid. However, there may also be unexpected situations where the SHMConfig enabling status becomes invalid. The system still reports an error saying "SHMConfig shoshould be enabled. ", the specific reason is unclear. It seems that CompizConfig is prone to this situation. In this case, a dialog box is displayed. If this happens, restart the system and you will be OK.
To make the above script run, you need to install python2.X, python-gtk2 these components.