I've set up a kiosk using Ubuntu 12.04, and I'd like to have it autologin after a user logs out or if the screen locks, in case someone manages to get back to lightdm or tries to login to the non-kiosk account after a reboot. I've tried setting display-setup-script in lightdm.conf to run xautolock to trigger restarting lightdm, but that just causes Ubuntu startup in low graphics mode. So basically, if lightdm is active instead of a user being logged in, log in the kiosk user.
4 Answers
Solution provided by Marc Balmer causes restart dead locks on my system driven by systemd. So I've ended up with following setting at /etc/lightdm/lightdm.conf:
session-cleanup-script=pkill -P1 -fx /usr/sbin/lightdm
The lightdm handles SIGTERM sent by pkill and gracefully shut downs and systemd makes service restarted.
- 266
- 3
- 10
create the script below in e.g. /etc/lightdm/restart and make it executable (chmod 755), then enter the path to the script in /etc/lightdm/lighdm.conf as session-cleanup-script value:
[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
autologin-user=kiosk
autologin-user-timeout=10
allow-guest=no
session-cleanup-script=/etc/lightdm/restart
and here is the script:
#!/bin/bash
trap "" SIGHUP SIGINT SIGTERM
PATH=$PATH:/sbin:/usr/sbin
service lightdm restart
This will restart lightdm whenever someone logs out, restarting the auto-login process.
- 78,313
- 42
- 165
- 222
- 111
- 2
If you're not wedded to lightdm in particular, then consider installing nodm, which is specifically designed for this kind of kiosk operation. I've been using it on a couple of machines (a MythTV frontend and a Web browser) for many years without problems.
- 8,460
- 3
- 26
- 50
-
Note that the author of _nodm_ writes in the [README](https://github.com/spanezz/nodm#this-repository-is-not-maintained): _I do not use nodm anymore. I do not maintain nodm anymore. To be really functional, nodm needs to be refactored to properly be a display manager with all that it requires in 2019 to be one. It currently does not make any effort to do so, and will break in obscure way as a result. Nobody should really need nodm anymore: lightdm's autologin now does the right thing out of the box: please use that._ – Petr Jan 06 '21 at 12:35
In my case, in /etc/lightdm/lightdm.conf:
session-cleanup-script=service lightdm restart
- 71,734
- 34
- 193
- 226
- 11
-
There's no reason to downvote this answer as the solution actually works. But you should put that line in a custom config file under the directory lightdm.conf.d/ instead of in the main config file. One line (under the heading `[Seat:*]` in the current version of lightdm). That's all it takes. No need for a separate script – bart Jul 05 '21 at 10:31