Skip to content

Instantly share code, notes, and snippets.

@tomwagner
Forked from KyleBruene/chrome-kiosk-setup.sh
Last active November 26, 2021 13:57
Show Gist options
  • Select an option

  • Save tomwagner/e2a3ec1095f4b4f0811089d96a16a03e to your computer and use it in GitHub Desktop.

Select an option

Save tomwagner/e2a3ec1095f4b4f0811089d96a16a03e to your computer and use it in GitHub Desktop.
Chrome Kiosk Setup
#!/bin/bash
if [ $# -ne 0 ]; then
echo "USAGE: mkkiosk.sh"
echo "Create new user 'kiosk' and configure LightDM to auto-login this user to a X session running only Chrome"
echo "in --kiosk mode."
exit 1
fi
set -x; set -e
date
# Try to make current user (admin/...) prefer 'ubuntu' to 'kiosk' for session type.
# TODO: currently doesn't seem to work, lightdm still suggests 'kiosk' session and requires manual clicking to change.
cat > ~/.dmrc << EOF
[Desktop]
Session=ubuntu
EOF
# Auto-create user 'kiosk'.
# http://askubuntu.com/a/321943/111779
# NOTE: auto-login is enabled later (autologin-user)
getent group kiosk || (
sudo su -c "groupadd kiosk"
sudo su -c "useradd kiosk -s /bin/bash -m -g kiosk"
)
# https://wiki.archlinux.org/index.php/Display_manager#Session_configuration
#
# - For Chrome flags, see:
# - http://peter.sh/experiments/chromium-command-line-switches/
# (via http://askubuntu.com/a/423632/111779)
# - TryExec:
# not sure what it does, but apparently must be just binary name if present.
# (see: https://www.virtualbox.org/svn/vbox/trunk/src/VBox/Additions/linux/lightdm-greeter/liblightdm-gobject-1.5.0/session.c)
# TODO: test if we can remove TryExec
# - IMPORTANT NOTE: If below settings are invalid, the session may just
# silently disappear as a choice in LightDM. You can then try to confirm this
# by looking in /var/log/lightdm/seat0-greeter.log for message "Ignoring
# sesion kiosk".
sudo bash -c 'cat > /usr/share/xsessions/kiosk.desktop' << EOF
[Desktop Entry]
Encoding=UTF-8
Name=Kiosk
Comment=Start a Chrome-based kiosk session
Exec=chromium-browser --start-fullscreen --start-maximized http://localhost/
#Exec=/usr/bin/google-chrome --kiosk --window-size=1281,1025 --window-position=0,0 --no-first-run --incognito --no-default-browser-check --disable-translate http://stackoverflow.com
TryExec=chromium-browser
Icon=google-chrome
EOF
sudo -u kiosk bash -c 'cat > ~kiosk/.dmrc' << EOF
[Desktop]
Session=kiosk
EOF
# See LightDM "help" in: /usr/share/doc/lightdm/lightdm.conf.gz
sudo bash -c 'cat > /usr/share/lightdm/lightdm.conf.d/99-kiosk.conf' << EOF
[Seat:*]
user-session=kiosk
EOF
# Setting below options in only 99-kiosk.conf doesn't seem enough (conflicts on autologin-user).
sudo bash -c 'cat > /etc/lightdm/lightdm.conf' << EOF
[Seat:*]
autologin-guest=false
autologin-user=kiosk
autologin-user-timeout=0
xserver-command = X -nocursor
EOF
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment