Ask HN: Turn Key Ubuntu Kiosk Mode

2 points by steviey19 ↗ HN
I’m building a home brew hardware device on the Ubuntu platform. There are 3-4 specific binaries loaded on to the device, and the user will at times need to be running one of them at a time.

Since I want the product to have a console feel, I’d like to boot directly into some sort of kiosk or app launcher, that would only allow the user to select from one of these preset binaries.

At the moment, I care less about actual security of the system (user breaking out of the sandbox), and more about ease of use and UX.

I’ve searched the web for an easy solution to this, but everything I’ve found seems like a lot of configuration and set up. I’ve also looked briefly into some of the game emulator Linux builds, but modifying these feels like overkill. I know some configuration will be necessary, but was hoping the community may be able to help me save some cycles with a few suggested applications or methods to achieve this!

I should also mention I’m open to both paid and free software options.

Any ideas?

10 comments

[ 5.1 ms ] story [ 26.7 ms ] thread
I don't know... this?

#!/bin/bash

while true; do echo "Please choose a binary to run:" echo "1) Binary 1" echo "2) Binary 2" echo "3) Binary 3" echo "4) Binary 4" echo "5) Exit"

    read -p "Enter choice: " choice

    case $choice in
        1) 
            /path/to/binary1
            ;;
        2)
            /path/to/binary2
            ;;
        3)
            /path/to/binary3
            ;;
        4)
            /path/to/binary4
            ;;
        5)
            echo "Exiting."
            exit 0
            ;;
        *)
            echo "Invalid choice, please try again."
            ;;
    esac
done

=======

To use this script:

Copy the script into a file on your device. You might name it launcher.sh, for example.

Make the script executable by running chmod +x launcher.sh.

Set this script as the login shell for your user. To do this, you'll need to add the full path to the script to /etc/shells, and then use chsh -s /full/path/to/launcher.sh username to change the login shell for username.

Configure your system to automatically log in as username. The method for doing this depends on which display manager you're using. If you're using LightDM, for example, you can do this by editing /etc/lightdm/lightdm.conf.

My apologies if this was too basic, but perhaps it's a starting point.
Not at all! This is great. I think at a minimum I need some kind of gui with an icon for each binary (something like a very basic app launcher I guess). But what I like about your solution is that it’s about as simple as I was hoping to be able to achieve!
If you're looking for super simple and you're a web dev, you could script together some page and use any server language to run the command.

For instance, use Electron as your app launcher.

Perfect it later if that's not your thing.

How do I make sure only the electron app is displayed at boot? Also, one of the apps is a full screen unity game, will this be affected by not having a full desktop loaded?
As far as making the electron app display at boot, my best guess would be to use it instead of the shell script I suggested earlier.... or, use the shell script, with the other steps commented-out, and just launch the electron app from there.

In terms of not having a full desktop loaded, I don't know. My guess is that if you're running the libraries to launch the graphics system in the first place, it should work.

However, luckily, I've been asking ChatGPT so far, haha, so I'll just ask it again.

One second.

To display only the Electron app or Unity game at boot, you'd typically want to create a systemd service that starts the systemd-nspawn container. You would then configure your display manager to automatically log into a session that only runs that service.

Here is a step-by-step guide:

*Step 1: Create a systemd service*

Create a systemd service file at `/etc/systemd/system/myapp.service` with the following contents:

```ini [Unit] Description=Start My App

[Service] ExecStart=/usr/bin/systemd-nspawn -D /path/to/container /root/launcher.sh Restart=always User=youruser Group=youruser

[Install] WantedBy=multi-user.target ```

Replace `/path/to/container` with the path to your container, and `youruser` with your username.

Enable the service to run at boot with:

```bash sudo systemctl enable myapp.service ```

*Step 2: Configure your display manager*

This step depends on which display manager you're using. If you're using LightDM, for example, you would create a new X session by creating a `.desktop` file at `/usr/share/xsessions/myapp.desktop` with the following contents:

```ini [Desktop Entry] Name=My App Exec=/usr/bin/systemctl start myapp.service Type=Application ```

You would then configure LightDM to automatically log in and start this session. Edit `/etc/lightdm/lightdm.conf` to include these lines:

```ini [Seat:*] autologin-user=youruser autologin-session=myapp ```

Replace `youruser` with your username.

This setup should start your systemd-nspawn container and display your Electron app or Unity game fullscreen at boot.

As for your question about running a Unity game without a full desktop environment: yes, it should be possible. Both Electron and Unity should be able to create their own windows without relying on a desktop environment. The one caveat is that there may be certain features that rely on the desktop environment (such as system notifications), which would not be available.

Note that this setup does not prevent the user from switching to other TTYs or sessions. If you want to restrict the user to your app, you'll need a more comprehensive "kiosk mode" setup that locks down the system at a lower level.

Amazing, thank you (and chatgpt).
Yeah, it's really helpful to prototype these kinds of things.
(comment deleted)