Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using lubuntu. I want to add a shortcut to toggle (turn on and off) my touchpad.

I know I need to edit the xml file in ~/.config/openbox (in my case it's lubuntu-rc.xml) as described here and here

I want it to trigger it when Fn and F5 are pressed (on my dell there is a touchpad icon on it, so I assume it triggers also a x86 keybind, dunno if that matters)

on my machine

 synclient TochPadOff=1

turns off the touchpad, and

  synclient TochPadOff=0

turns it on again

the command

synclient

without any options returns this list

Parameter settings:
    LeftEdge = 300
    RightEdge = 1700
    TopEdge = 210
    BottomEdge = 1190
    FingerLow = 12
    FingerHigh = 15
    MaxTapTime = 180
    MaxTapMove = 107
    MaxDoubleTapTime = 180
    SingleTapTimeout = 180
    ClickTime = 100
    EmulateMidButtonTime = 75
    EmulateTwoFingerMinZ = 141
    EmulateTwoFingerMinW = 7
    VertScrollDelta = 48
    HorizScrollDelta = 48
    VertEdgeScroll = 1
    HorizEdgeScroll = 0
    CornerCoasting = 0
    VertTwoFingerScroll = 1
    HorizTwoFingerScroll = 0
    MinSpeed = 1
    MaxSpeed = 1.75
    AccelFactor = 0.0819336
    TouchpadOff = 0
    LockedDrags = 0
    LockedDragTimeout = 5000
    RTCornerButton = 2
    RBCornerButton = 3
    LTCornerButton = 0
    LBCornerButton = 0
    TapButton1 = 1
    TapButton2 = 3
    TapButton3 = 0
    ClickFinger1 = 1
    ClickFinger2 = 1
    ClickFinger3 = 0
    CircularScrolling = 0
    CircScrollDelta = 0.1
    CircScrollTrigger = 0
    CircularPad = 0
    PalmDetect = 0
    PalmMinWidth = 10
    PalmMinZ = 100
    CoastingSpeed = 20
    CoastingFriction = 50
    PressureMotionMinZ = 15
    PressureMotionMaxZ = 80
    PressureMotionMinFactor = 1
    PressureMotionMaxFactor = 1
    ResolutionDetect = 1
    GrabEventDevice = 1
    TapAndDragGesture = 1
    AreaLeftEdge = 0
    AreaRightEdge = 0
    AreaTopEdge = 0
    AreaBottomEdge = 0
    HorizHysteresis = 12
    VertHysteresis = 12
    ClickPad = 0

as you can see, there is the line "TouchpadOff = 0".

So what I'm basically asking for is someone who knows how to work grep and regular expressions to tell me how to write a shell script that reads the output of snyclient and executes "synclient TochPadOff=0" or "synclient TochPadOff=1" accordingly . If found this script that does something very similar , but I'm struggeling on the grep part.

If found a generic toggle script , but I think grepping the info is cleaner.

I also already know how to bind a shellscript to a keyboardshortcut from that example.

help greatly appreciated .

share|improve this question
up vote 2 down vote accepted

This works for me:

  #!/bin/sh
  TOGGLE=$HOME/.toggle

  if [ ! -e $TOGGLE ]; then
    touch $TOGGLE
    synclient TouchPadOff=1 &
  else
    rm $TOGGLE
    synclient TouchPadOff=0 &
  fi

exit 0

There doesn't seem to be need for grep. Also, I'm not too sure that Openbox likes Fn in any rc.xml but see Nivatius' answer for how to use keypresses involving Fn. I've only ever used Super, Control, Alt, and Shift. I can bind that script to Control+Shift+F5, for example.

<keybind key="C-S-F5">        # Toggle touchpad
  <action name="Execute"><command>/home/dkb/bin/toggle-touchpad</command></action>
</keybind>
share|improve this answer
    
thanks. with xev I found the keycode for the Fn+F5 combo – Nivatius Jan 25 at 12:11

I settled for this solution:

script

# This shell script is PUBLIC DOMAIN. You may do whatever you want with it.

TOGGLE=$HOME/.touchpadtoggle

if [ ! -e $TOGGLE ]; then
    touch $TOGGLE
    synclient TouchpadOff=1
else
    rm $TOGGLE
    synclient TouchpadOff=0
fi

config file

<!-- toggle touchpad with fn key fn+F5 -->
    <keybind key="XF86TouchpadToggle">
     <action name="Execute">
          <command>~/scripts/touchpadtoggle.sh</command>
         </action>
    </keybind>

The path in command of course, needs to point to your script

I used xev to find out the XF code of fn+F5:

run xev, press Fn key and F5 then close the popup, scroll up in the long output and look out for the keycode.

share|improve this answer
    
Thanks for explaining how to dig out the Fn+F5 code. BTW, this code cleans up the xev output: xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'. I found it here: wiki.archlinux.org/index.php/Extra_keyboard_keys#In_Xorg – DK Bose Jan 25 at 12:28

Check out my OpenBox config files, you'll find a keybind in my rc.xml and a script in my scripts directory that will toggle your touchpad whenever you press CTRL+ALT+m

https://github.com/mladoux/openbox

I pulled the script off the Arch Linux wiki for the Synaptics touchpad devices. You can always change the key on the keybind to be F5 or whatever you want it to be. And unlike the script in this thread, it also disables the buttons. Enjoy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.