Finally got it to work ! It appears running xinput
from a sleep.d
script requires some tweaks. Here is what I did. Hope it will be of some use to someone.
So I have one script called 40mouse_slow
I put in /etc/pm/sleep.d
. The 40
is used for ordering. On resume, low numbers start last. User scripts should use 00
to 49
. Make sure the script has execution rights. Here is the script :
#!/bin/sh
case "$1" in
resume|thaw)
/home/yannick/scripts/mouse_slow.sh &
;;
*)
# Nothing.
;;
esac
It only says the script /home/yannick/scripts/mouse_slow.sh
should be launched in the background when computer resumes. I tried launching it not in background, but that broke resuming (network didn't work, for example).
Here is /home/yannick/scripts/mouse_slow.sh
. Also make sure it has execution rights :
#!/bin/sh
export DISPLAY=:0.0
id=`su yannick -c "xinput" | grep 'PID:400a' | cut -c58-60`
su yannick -c "xinput set-prop $id 'Device Accel Constant Deceleration' 2.5"
The second line is just to find the id of my mouse. As for the two other lines, they ilustrate the two things I found had to be done to make xinput
work when it is called from a script in sleep.d
:
DISPLAY
must be set and exported
- the user executing
xinput
must be the user running X, not root.