EDIT (revision 4)
According to this ubuntuforums.org post, upstart cookbook and CameronNemo's answer, I tried to change the first line with
start on login-session-start
and I moved the conf file to /etc/init/
. The script now runs, but it does not work. The log file reports Cannot connect to X server
. I tried to add to the script
export DISPLAY=":0"
export XAUTHORITY="/home/marco/.Xauthority"
but it don't work yet. Error is Invalid MIT-MAGIC-COOKIE-1 key
.
Note that I have no problem to run sudo xinput list
after login.
ORIGINAL ANSWER
I'm using Lubuntu 14.04 and I want to disable the touchpad at boot if mouse is connected. For this purpose, I created this ~/.config/upstart/touchpad.conf
upstart job:
start on desktop-start
script
mouse_state_old=-1
touchpad_id="$(xinput list | grep -i touchpad | grep -oP "\bid\s*=\s*\K\d+")"
while true ; do
mouse_state="$(xinput list | grep -ci mouse)"
if [ "$mouse_state" -ne "$mouse_state_old" ] ; then
if [ "$mouse_state" -gt 0 ] ; then
killall syndaemon
xinput disable "$touchpad_id"
else
xinput enable "$touchpad_id"
syndaemon -m 100 -i 1 -k -d
fi
fi
mouse_state_old="$mouse_state"
sleep 3
done
end script
This job works, but only after I log into the OS. I want the touchpad disabled also before I log in, at login screen.
INFOS NO MORE NEEDED AND SIMPLY WRONG: according to the cookbook, it seems that lightdm does not emit the correct event. If I run manually
/sbin/initctl -q emit login-session-start DISPLAY_MANAGER=lightdm
the upstart script is invoked. So I created a /etc/lightdm/lightdm.conf.d/90-upstart_login.conf
conf file with
[SeatDefaults]
greeter-setup-script=/home/marco/.local/usr/bin/all/upstart_login.sh
and the /home/marco/.local/usr/bin/all/upstart_login.sh
script with
#!/bin/sh
/sbin/initctl -q emit login-session-start DISPLAY_MANAGER=lightdm
It works if invoked manually from bash but not at boot.
I have lightdm version 1.10.1-0ubuntu1, so it should emit the event.
/etc/rc.local
from bash works, so the script is correct.