Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like use my desktop computer as a normal desktop computer at one time, and a "Steam Box" another. By default I want the computer to boot as a normal desktop; but I want it to be able to boot itself into Steam Box mode without using a keyboard - as the only thing connected to a Steam Box will be a wireless controller.

Current plan is

  1. Insert a USB drive (the dongle)
  2. Let grub do it's normal booting into the default runlevel 2 (Debian's default GUI with network runlevel)
  3. Put a low level (number) script in runlevel 2 which detects if the USB drive is plugged in and run "init 3" to switch to runlevel 3 if the usb drive exists
  4. Put a script in runlevel 3 which changes /var/lib/AccountsService/users/[username] file to load gnome-fallback instead of regular gnome
  5. Have a startup script running for the user in Gnome which detects if the runlevel is 3 and launches Steam into big picture mode if it is.

Some extra info:

  • I like the idea of using runlevels because I can later tweak runlevel 3 to be more optimised for games
  • gnome-fallback mode is preferable to normal gnome as it interferes with fullscreen apps less
  • I have configured GDM to boot into Gnome for the user account without entering a password

This is what I have so far...

Step 3 script (switch to runlevel 3)

#!/bin/sh
### BEGIN INIT INFO
# Provides:          steam_on_runlevel_3
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2
# Default-Stop:      0
# Short-Description: Changes runlevel to 3 if dongle is inserted. Runlevel3 is the steam runlevel.
# Description:       .
### END INIT INFO

case "$1" in

start)

    if [ -e /dev/disk/by-uuid/b8d5a7f2-b272-4e70-ba4d-04620741f0a0 ]
    then
        init 3
    fi

;;

stop)

    echo

;;

reload|restart|force-reload)

    if [ -e /dev/disk/by-uuid/b8d5a7f2-b272-4e70-ba4d-04620741f0a0 ]
    then
        init 3
    fi

;;

*)

echo "Usage: [this] {start|stop|restart|reload|force-reload}" >&2

exit 1

;;

esac

exit 0

Step 4 script (change default window manager to gnome-fallback)

#!/bin/sh
### BEGIN INIT INFO
# Provides:          setgnomeclassic
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     3
# Default-Stop:      0
# Short-Description: Set ben's WM to gnome-fallback when in runlevel3
# Description:       .
### END INIT INFO

case "$1" in

start)

    python /home/ben/setdefaultwm.py ben gnome-fallback

;;

stop)

    python /home/ben/setdefaultwm.py ben gnome

;;

reload|restart|force-reload)

    python /home/ben/setdefaultwm.py ben gnome-fallback

;;

*)

echo "Usage: [this] {start|stop|restart|reload|force-reload}" >&2

exit 1

;;

esac

exit 0

Step 5 script (load Steam big picture mode)

if [ "$(who -r | awk '{ print $2}')" -eq 3 ]
then
  steam -bigpicture
fi

The mystery Python script just uses the command line arguments to edit the specified user file (in /var/lib/AccountService/users) and set the specified window manager.

I tried a few different things with changing the Required-Start/Stop values but I don't understand runlevels and init well enough to get it working completely. Using the above scripts as they are, the computer will recognise the dongle, switch to runlevel 3, change the window manager to gnome-fallback, but then stops at a (TTY?) login prompt. So almost there :-P

Can you see where I've muddled things up or ways to improve the scripts / process?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.