1

I have a 15.10 64bit machine with multiple user accounts.
Normally, I select Ubuntu in GRUB, it boots and shows me the login screen, I select an account, enter the password and start my applications.

This is ok and should stay that way, but I would love to have another option in the GRUB menu:

If I select that one, it should boot the same Ubuntu installation, but automatically log into one specific user account (which password-protected) and start a script, which may not be launched if I log in normally.
As the auto-login bypasses the account password, I would also love to password protect this GRUB boot option, so that I have to enter my password (or a different one) into GRUB before it boots this single options.

Is it possible to set something like this up? How would I have to do it?

Byte Commander
  • 110,243

1 Answers1

2

Work in progress

This can be accomplished by using:

  1. a custom X session which starts a basic window manager and runs the script
  2. a custom configuration for LightDM which will autologin your user and use the above session
  3. a custom service for LightDM which will use the above configuration
  4. appropriate kernel parameters to disable the normal LightDM service and start the custom one
  5. GRUB configuration to automatically create entries with the above parameters, with password protection

For this example, I will show how to setup a kiosk mode using Google Chrome.

The script

#! /bin/sh
metacity &
while true
do 
    google-chrome --start-maximized
    if zenity --question --text='Do you want to logout?' --title='Logout'
    then
        exit
    fi
done

Keep it at, say /usr/local/bin/chrome-kiosk.sh, make it executable. Note that I use metacity for a simple window manager that provides me with a workable setup without further configuration.

The X session

[Desktop Entry]
Name=Chrome
Comment=This session logs runs a Google Chrome kiosk
Exec=/usr/local/bin/chrome-kiosk.sh
Icon=google-chrome
Type=Application
X-LightDM-DesktopName=Chrome

Save it at /usr/share/xsessions/chrome.desktop. If you use a different script, change at least the Exec line accordingly.

The LightDM configuration

[Seat:*]
autologin-guest=false
autologin-user=username
autologin-user-timeout=0
autologin-session=chrome

Save it as /etc/lightdm/autologin-lightdm.conf. Replace username with your desired user name.

The LightDM service

systemctl cat lightdm.service | 
  sed '/ExecStart/s/$/ --config=/etc/lightdm/autologin-lightdm.conf' |
  sudo tee /etc/systemd/system/autologin-lightdm.service

This creates a custom copy of the default lightdm.service named autologin-lightdm.service at /etc/systemd/system, with the ExecStart line changed to:

ExecStart=/usr/sbin/lightdm --config /etc/lightdm/autologin-lightdm.conf

The kernel paramaters

To test this out, at the GRUB menu, press e to edit the Ubuntu entry. Find the linux line, and append:

systemd.mask=display-manager.service systemd.wants=autologin-lightdm.service

(You can omit the .service extensions.)

Press CtrlX. You should be logged into the user and have a maximized Google Chrome window.

GRUB configuration

TBD.

muru
  • 207,228