Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

Earlier I asked a similar question, but that one was about running system-level scripts.

I have a script that runs a series of xinput commands in order to enable two-finger scrolling on my touchpad. It has to be re-run every time the computer sleeps and wakes up again, and it has to be run from within the X11 session. How do I trigger a script to be run on my X11 desktop when the computer wakes up?

P.S. I suspect there's a way to do this with DBUS, but I' m fuzzy on the specifics. Maybe someone with stronger DBUS-fu could point me in the right direction.

share|improve this question

If you have gnome-control-center installed, run gnome-mouse-properties and visit Touchpad tab and click on Two-finger scrolling:

enter image description here

It works very well, and across wake-ups too. So, unless you are using your scripts for something else too, throw them away :)

share|improve this answer
Unfortunately, for whatever reason this does not work for my touchpad. The touchpad supports two-finger scrolling just fine, but the GNOME mouse panel shows the option grayed-out. So I have to use a script. – Avdi Mar 11 '11 at 20:13
How about filing a bug (with a patch if you find the code) in Gnome with details of your touchpad model and how it can be set to two finger scrolling so the option can get enabled and other people don't have to hack it with scripts? – Caleb Jun 10 '11 at 9:10
@Caleb: answering to the wrong person? – Tshepang Jun 10 '11 at 10:13
That should have been @Avdi, it was in regard to his comment. I would say the best way is to help get gnome fixed so it works instead of inventing ways to hack it. – Caleb Jun 10 '11 at 11:02

Try exporting the DISPLAY variable for existing X sessions.

Assuming it's :0, add the following to the start of your script (well, at least before you run any X-related commands).

export DISPLAY=":0"

I think you may also need to grant authorization to the local host, by running the following in one of your existing X terminals. (I'm assuming it's you, and only you on this system, if not, this will give other local users access to your X display)

xhost +localhost

It's been a while since I've really played with X, so hopefully someone can come along and correct me.

share|improve this answer
Thanks. I'm hoping there's a different way strictly in user-space - I suspect there's a way to do this with DBUS, but my DBUS-fu is not strong enough. – Avdi Mar 11 '11 at 20:14

EDIT: It appears my reading comprehension is impaired, I don't think this will help with the X11 aspect, sorry.

If your system uses the pm-utils package for sleep/wake you can put a script in

Here's a script I use to attach my serial mouse after hibernate:


# Action script to ensure that serial mouse works
# after a hibernate/suspend
# Copyright: Copyright (c) 2009 Michael Vogt
# License:   GPL-2



# pm-action(8) - <action> <suspend method>

case "${1}" in
        # nothing
        inputattach --daemon -ms3 /dev/ttyS0

I saved this as 00_attach_serial_mouse.

share|improve this answer

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.