Can I use Upstart to start a script which requires the user's X session?

Posted by ledneb on Server Fault See other posts from Server Fault or by ledneb
Published on 2012-03-07T14:26:10Z Indexed on 2012/03/28 17:33 UTC
Read the original article Hit count: 179

Filed under:
|
|
|
|

I wrote a script which greps through the output of synclient to determine whether a laptop's touchpad has miraculously turned itself off (Ubuntu seems to /love/ doing this recently) and, if so, turns it back on.

The script is something like this:

#!/bin/bash
while true ; do
    if [ `synclient | grep -e"TouchpadOff[\s]*1" | wc -l` -ge 1 ] ; then
        synclient TouchpadOff=0
    fi
    sleep(3)
done

(I don't have the laptop to hand right now but you get the point! I will update later when I'm at my laptop if that's incorrect)

So I tried running this as an upstart script so my touchpad can heal itself without any interaction. But it seems synclient doesn't find the current user's X session when my script is upstart'ed.

I tried running it by using something like su -c myscript.sh ledneb in my script stanza, but to no avail.

Should I be looking in the direction of /etc/X11/xinit/xinitrc rather than upstart?

Is there a proper way to have this script run in the context of the current (or even a hard-coded) user's x session?

© Server Fault or respective owner

Related posts about ubuntu

Related posts about upstart