1

My mouse was too fast for my taste so I decreased its speed using a xinput command :

xinput set-prop $id "Device Accel Constant Deceleration" 2.5

I put the command in ~/.profile so that it executes on startup. At startup, it always works.

My problem is that the setting seems to be reset when my computer resumes after standby. Not always, maybe half the time.

I tried to put the command in a script in /etc/pm/sleep.d/, and it was executed but for some reason didn't work.

Any ideas ? Answers to this question suggests xinput commands should go in a .desktop file : would that change anything ?

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .