Skip to content

Instantly share code, notes, and snippets.

@m-shibata
Created July 10, 2020 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-shibata/56f8718ff446d48e6502330b7657a2bb to your computer and use it in GitHub Desktop.
Save m-shibata/56f8718ff446d48e6502330b7657a2bb to your computer and use it in GitHub Desktop.
steam-launcher
#!/bin/sh
CONTAINER="$1"
TITLE="Steam Launcher"
if [ -z "${CONTAINER}" ]; then
notify-send "${TITLE}" "Please specify container name"
exit 1
fi
# check and start container
status=$(lxc list --format csv -c s "^${CONTAINER}$")
if [ "$status" != "RUNNING" ]; then
lxc start "${CONTAINER}"
lxc exec "${CONTAINER}" -- cloud-init status --wait
status=$(lxc list --format csv -c s "^${CONTAINER}$")
if [ "$status" != "RUNNING" ]; then
notify-send "${TITLE}" "Failed to start \"${CONTAINER}\" container"
exit 1
fi
fi
JOYSTICK=""
for d in $(lxc exec "${CONTAINER}" -- sh -c 'ls /dev/input/js*' 2>/dev/null) ; do
if lxc exec "${CONTAINER}" -- test -c "$d" ; then
DEVPATH=$(lxc exec "${CONTAINER}" -- udevadm info -q path "$d" | sed 's,input/.*$,,')
for h in $(lxc exec "${CONTAINER}" -- sh -c 'ls /dev/hidraw*' 2>/dev/null) ; do
if [ "$(lxc exec "${CONTAINER}" -- udevadm info -q path "$h" | sed 's,hidraw/.*$,,')" = "${DEVPATH}" ]; then
lxc exec "${CONTAINER}" -- chmod g+rw "$h"
lxc exec "${CONTAINER}" -- chgrp input "$h"
JOYSTICK="$h"
fi
done
fi
done
if [ -z "${JOYSTICK}" ]; then
notify-send "${TITLE}" "Not found JoyStick device. Please re-plug JoyStick."
exit 1
fi
lxc exec "${CONTAINER}" -- sudo --user=ubuntu --login steam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment