Created
July 10, 2020 20:57
-
-
Save m-shibata/56f8718ff446d48e6502330b7657a2bb to your computer and use it in GitHub Desktop.
steam-launcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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