Add shortcut keys in linux to open or close the TouchPad

Source: Internet
Author: User
In linux, two commands are used to enable or disable the TouchPad: synclienttouchpadoff1 -- disable the TouchPad command: synclienttouchpadoff0 -- the preceding command fails to enable the TouchPad www.2cto.com. However, in linux, two commands are used to enable or disable the TouchPad by adding a shortcut key.
Command: synclient touchpadoff = 1 -- disable touchpad command: synclient touchpadoff = 0 -- enable the TouchPad www.2cto.com command is not successful, please look down. But you need to open option SHMConfig first. Otherwise, the error "Can't access shared memery area. SHMconfig disabled?" will be returned when you run these two commands? To open this option, you need to add the following file: gksudo gedit/etc/hal/fdi/policy/shmconfig. fdi:   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 enable the TouchPad. during running, it will switch between the two statuses. # 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: www.2cto.com 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 shoshould 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 to set it to executable. To bind the shortcut key, select commands in CompizConfig and add the command:/home/vivian/lockpad. py www.2cto.com to 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. Author tycomputer
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.