Find the answer to your Linux question:
Results 1 to 2 of 2
Summary: How to turn a touchpad on and off with ease in the GNOME Desktop Environment. Turning a touchpad on and off is not provided as an easy option in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie chadders's Avatar
    Join Date
    Jan 2007
    Location
    Earth.
    Posts
    101

    Turning a touchpad on and off in GNOME - Tutorial


    Summary: How to turn a touchpad on and off with ease in the GNOME Desktop Environment.

    Turning a touchpad on and off is not provided as an easy option in GNOME by default. This can be corrected with a simple shell script.

    Firstly ensure that the line 'Option "ShmConfig" "true"' is included under the touchpad section of your '/etc/X11/xorg.conf' file. This section should look something like this:

    Code:
    Section "InputDevice"
            Identifier "Synaptics Touchpad"
            Driver "synaptics"
            Option "SendCoreEvents" "true"
            Option "Device" "/dev/psaux"
            Option "Protocol" "auto-dev"
            Option "HorizScrollDelta" "0"
            Option "ShmConfig" "true"
    EndSection
    Now that that's set up, the following shell script will work. Copy and paste the code into a file and save it as a shell script in some directory. I saved mine in '~/.custom/tps.sh', tps stands for TouchPad Switcher.

    Code:
    question="`synclient -l | grep TouchpadOff`"
    
    if [[ $(echo $question | tr -d ' ') == 'TouchpadOff=1' ]]
    then
    
    synclient TouchpadOff=0
    
    else
    
    synclient TouchpadOff=1
    
    fi
    That's most of the work done. By running that script it should turn you touchpad on if it's off and off if it's on. This makes switching the touchpad on and off a lot easier, but still not the easiest. Follow one of the tutorials below to add either a key binding (keyboard shortcut) to the shell script or turn it into a command line command.

    Creating Keyboard Shortcuts

    Summary: How to create a key binding (keyboard shortcut) in the GNOME Desktop Environment.

    You'll need to ensure that you have the 'Configuration Editor'. In Debian GNU/Linux this is usually located under 'Applications -> System Tools -> Configuration Editor'.

    In the configuration editor go to the metacity part ('/ -> apps -> metacity').

    Under 'keybinding_commands' select anything from command_1 to command_10 and give it the value 'sh <Location of shell script>' or whatever command you want command_x to run. For example say you wanted to run a shell script to turn your touch pad on and off (see here), I could type 'sh /home/username/.custom/tps.sh'.

    Now that we have told command_x to run a command when initiated (lets assume command_x is command_1 for now), we then need to give it a key binding. To do this go to 'global_keybindings' and select the corresponding attribute (Name), e.g. run_command_1 in this case. KDE uses the key combination Ctrl+Alt+q to turn on/off their touchpad so lets do the same here. Give run_command_1 the value '<Ctrl><Alt>q'.

    Adding Custom Command Line Commands

    Summary: How to add custom command line commands.

    This tutorial will be split into two parts. Part one will show you how to give a command another name so you can call it up more easily. Part 2 will show you how to add a shell script as if its a command.

    Part 1: Giving a command more names.

    Simply create a symbolic link in the '/usr/bin' directory to the same program. For example if I wanted to make the command 'gnome-terminal' able to be called by typing 'cmd' I would make the following symbolic link (you must be in super-user mode ('$ su -')):

    Code:
    # ln -s /usr/bin/gnome-terminal /usr/bin/cmd
    Now the commands 'gnome-terminal' and 'cmd' will both call up the Gnome Terminal.

    Part 2: Running shell scripts as a command.

    A similar task needs to be done here however the shell script is copied to the '/usr/bin' directory. There is no need for the '.sh' extension to the script command as that will only add the need to type more. Taking the example of the touchpad switcher (tps for short), lets make this into a command line command.

    Code:
    # cp /home/username/.custom/tps.sh /usr/bin/tps
    Now when I type 'tps' into a terminal the touchpad will start/stop working.

    ---

    For anyone you might have had questions on this, I hope it has helped and that I haven't been too over wordy lol.

    Cheers.
    That's my two pence worth.

    Chadders.

    Use my themes... click here.

    New to Linux Forums, or Linux in general? Start here.
    Get Debian (Etch) here.
    Registered Linux user #442544.

  2. #2
    Just Joined!
    Join Date
    Sep 2007
    Posts
    7
    excellant tutorial. thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •