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

On Ubuntu 13.04 I have to manually configure the touchpad since a bug prevents me using the standard configuration tool (changes don't save). However I created a script that sets up velocity, acceleration and scrolling, configured it to run at sartup and it works. The problem rises when I resume after suspension: especially the scrolling settings (the easiest to check) disappear. Following other questions and answers I wrote this script (which contains the same commands I used in the over-mentioned one) located in /etc/pm/sleep.d/ZZtouchpad:

case "$1" in
        xinput  --set-prop "CyPS/2 Cypress Trackpad" "Device Accel Constant Deceleration" 2
        xinput  --set-prop "CyPS/2 Cypress Trackpad" "Device Accel Velocity Scaling" 35
        xinput  --set-prop "CyPS/2 Cypress Trackpad" "Synaptics Scrolling Distance" -20, -20

But it doesn't work at all.

Thnks for help!


I found out that the script works when suspending with pm-suspend or pm-suspend-hybrid, but when suspending from the system menu or closing the laptop lid it doesn't. It seems the error is 'unable to connect to X server'.

So, the question better be rephrased: where should I put those commands for them to be executed when the X session is resumed? I tried ~/.xinitrc, a file under ~/.xinitrc.d and ~/.xsessionrc. Any suggestions?

share|improve this question

I had a similar problem. The issue is to connect to the X server. I solved it by stealing from /etc/acpi/ Put the following into /etc/pm/sleep.d/99_setup_touchpad.

#! /bin/sh

. /usr/share/acpi-support/power-funcs

case "$1" in
        if pidof xscreensaver > /dev/null; then
            for x in /tmp/.X11-unix/*; do
                displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
                if [ x"$XAUTHORITY" != x"" ]; then
                    export DISPLAY=":$displaynum"
                    su $user -c "xinput set-prop 'CyPS/2 Cypress Trackpad' 'Device Accel Constant Deceleration' 2"
                    su $user -c "xinput set-prop 'CyPS/2 Cypress Trackpad' 'Device Accel Velocity Scaling' 35"
                    su $user -c "xinput set-prop 'CyPS/2 Cypress Trackpad' 'Synaptics Scrolling Distance' -20, -20"
        # Nothing.

Finally make the file executable: chmod 755 /etc/pm/sleep.d/99_setup_touchpad.

Note: I'm usually the only one logged in via X on my laptop. So the loop is just one iteration. I don't know what happens if there are more than one sesssions live at the same time. The above is good enough for me.

share|improve this answer
I am too usually the only one logged in, but sadly this didn't work... – Earendil Sep 1 '13 at 20:34

Your Answer


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.