2

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.

2

2 Answers 2

1

You are mixing up system and session jobs and events. lightdm emits the event just fine, but to the system instance of Upstart. Copy your ~/.config/upstart/touchpad.conf to /etc/init/ and change the start on event to login-session-start.

3
  • You're right. Now the script runs, but the script reports me Cannot connect to X server. See "EDIT NUMBER 2". Oct 15, 2014 at 7:55
  • Maybe add a stanza, env DISPLAY=:0, to the job? Oct 15, 2014 at 21:30
  • I've added it with export without success. Oct 16, 2014 at 7:17
0

Instead of using Upstart, you can try to place your script snippet into /etc/X11/session.d/.

Make sure that it is by the name of 99local and that it does not have a #!bin/sh header.

It also should not be executable.

This will ensure that your script is run after the xsession is set up and that it always runs, since the scripts in that directory are always run when an X server is started.

1
  • Nope, it doesn't work. I added a /etc/X11/Xsession.d/99x11-local with a sleep 20 ; xinput disable $id, nothing happens. Nov 10, 2014 at 22:37

You must log in to answer this question.

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