Direct answer
In order to achieve your goal (of running an X-session dependent user-space script when your machine resumes) you must:
- run the script as the appropriate user; and
- ensure the DISPLAY variable is set.
I would move the line sleep 15 && synclient TapButton2=2 TapButton3=3
to a separate file say /usr/local/sbin/setupTouchpad.sh
and replace the line with:
export DISPLAY=:0
su -c - <yourusername> /usr/local/sbin/setupTouchpad.sh
Where <yourusername>
should be replaced. Note that it is still a good idea to have some sleep time to be sure the system is awake before running the code. Also, be sure to chmod +x
that setupTouchpad.sh
script.
A better way
The problem with the above is that you have to hard-code your username (or use some hackish way to discover which user is logged in and has the active X session). It's better to set system-wide touchpad settings for X.
These options may be set in /usr/share/X11/xorg.conf.d/
For me, the correct file to edit is 50-synaptics.conf
here I've set options, here's a portion of that file:
Section "InputClass"
Identifier "touchpad catchall"
Driver "synaptics"
MatchIsTouchpad "on"
Option "TapButton2" "2"
Option "TapButton3" "3"
# Etc...
EndSection
As you may already be aware, to see valid options simply run synclient
.
Note you must restart X for these changes to take effect. To do so in Ubuntu, for example, you can run sudo /etc/init.d/lightdm restart
To preview your changes you may try running the following line (or some variant). Remove | bash
from the end to see the commands it's issuing.
cat /usr/share/X11/xorg.conf.d/50-synaptics.conf | grep Option | grep -v "^\#" | awk '{print "synclient " $2 "=" $3}' | sed 's/\"//g' | bash
If you Google around for touchpad settings synaptics xorg.conf.d
you'll find a few good overviews of options, also.
References