Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Last active April 18, 2024 17:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pythoninthegrass/506e13de50a10ad2deeeac8d7098a16e to your computer and use it in GitHub Desktop.
Save pythoninthegrass/506e13de50a10ad2deeeac8d7098a16e to your computer and use it in GitHub Desktop.
sunshine, gamescope + steam
#!/usr/bin/env bash
# TODO: test wayland gamescope session
export DISPLAY=:0 # vnc
export WAYLAND_DISPLAY=:2 # xwayland
export DXVK_HDR=1
export ENABLE_GAMESCOPE_WSI=1
# Check existing X server
start_x() {
pgrep X >/dev/null
if [[ $? -ne 0 ]]; then
echo "Starting X server"
startx &>/dev/null &
if [[ $? -eq 0 ]]; then
echo "X server started successfully"
else
echo "X server failed to start"
fi
else
echo "X server already running"
fi
}
# Check if sunshine is already running
start_sunshine() {
pgrep sunshine >/dev/null
if [[ $? -ne 0 ]]; then
sudo ~/.local/bin/sunshine-setup.sh
echo "Starting Sunshine!"
sunshine > /dev/null &
if [[ $? -eq 0 ]]; then
echo "Sunshine started successfully"
else
echo "Sunshine failed to start"
fi
else
echo "Sunshine is already running"
fi
}
# start steam via gamescope
start_gamescope() {
pgrep steam >/dev/null
if [[ $? -ne 0 ]]; then
echo "Starting Steam via Gamescope"
gamescope --headless -e \
-W 1920 -H 1080 \
--disable-color-management \
-- steam \
-gamepadui \
-steamos3 \
-steampal \
-steamdeck \
-pipewire-dmabuf \
&> /dev/null &
if [[ $? -eq 0 ]]; then
echo "Steam started successfully"
else
echo "Steam failed to start"
fi
else
echo "Steam is already running"
fi
}
# Add any other Programs that you want to startup automatically
start_etc() {
firefox &> /dev/null &
kdeconnect-app &> /dev/null &
}
stop_process() {
sudo killall $1 2&> /dev/null || echo "$1 not running"
}
main() {
case $1 in
"on")
start_x
start_gamescope
start_sunshine
;;
"off")
set -a procs
procs=("gamescope" "sunshine" "steam" "startx")
for p in "${procs[@]}"; do
stop_process $p
done
;;
""|*)
echo -e "USAGE:\t./$(basename $0) <on|off>"
;;
esac
# start_etc
}
main "$@"
@pythoninthegrass
Copy link
Author

pythoninthegrass commented Apr 15, 2024

λ ln -s $(pwd)/game.sh ~/.local/bin/game

λ game
USAGE:  ./game <on|off>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment