Skip to content

Instantly share code, notes, and snippets.

@KiyoNetcat
Last active February 6, 2023 20:12
Show Gist options
  • Select an option

  • Save KiyoNetcat/c5132fcd2c99a847cdc1b79431caaba8 to your computer and use it in GitHub Desktop.

Select an option

Save KiyoNetcat/c5132fcd2c99a847cdc1b79431caaba8 to your computer and use it in GitHub Desktop.
Script to automate setting up and running Games on Whales
#!/bin/bash
# Create Necessary Files in Temp
cd /tmp
if [ ! -d "/tmp/gow" ]; then git clone https://github.com/games-on-whales/gow.git; fi
cd gow
wget -O /tmp/edid.txt https://raw.githubusercontent.com/games-on-whales/gow/master/docs/modules/ROOT/examples/edid.txt
echo 'Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "AllowEmptyInitialConfiguration" "True"
Option "UseDisplayDevice" "DP-0"
Option "CustomEDID" "DP-0:/home/retro/edid.txt"
Option "ConnectedMonitor" "DP-0"
SubSection "Display"
Depth 24
EndSubSection
EndSection' > /tmp/xorg-screen.conf
# Create and Apply Patches
if [ ! -f "/tmp/headless.env.patch" ]; then
echo '--- headless.env 2023-02-06 06:19:10.872334665 +0000
+++ newheadless.env 2023-02-06 06:20:41.917369316 +0000
@@ -13,7 +13,7 @@
# Change these to suit your preferences
XORG_RESOLUTION=1920x1080
XORG_REFRESH_RATE=60
-XORG_DISPLAY_PORT=HDMI-0
+XORG_DISPLAY_PORT=DP-0
XORG_FORCE_RESOLUTION=false
PULSE_SERVER=unix:/tmp/pulse/pulse-socket' > /tmp/headless.env.patch;
patch -u /tmp/gow/env/headless.env -i /tmp/headless.env.patch;
fi
if [ ! -f "/tmp/headless.yml.patch" ]; then
echo '--- headless.yml 2023-02-06 05:48:52.709856907 +0000
+++ newheadless.yml 2023-02-06 06:28:56.415576889 +0000
@@ -24,6 +24,10 @@
# The xorg socket, will be populated when up and running
- ${XORG_SOCKET}:/tmp/.X11-unix
# run-gow: xorg_driver
+ # START ADDING HERE
+ - /tmp/edid.txt:/home/retro/edid.txt:ro
+ - /tmp/xorg-screen.conf:/usr/share/X11/xorg.conf.d/01-xorg-screen.conf:ro
+ # END ADDING HERE
ipc: ${XORG_IPC} # Needed for MIT-SHM, removing this should cause a performance hit see https://github.com/jessfraz/dockerfiles/issues/359
' > /tmp/headless.yml.patch;
patch -u /tmp/gow/compose/platforms/headless.yml -i /tmp/headless.yml.patch;
fi
# Create Home Directory Stuff
if [ ! -d "$HOME/.gow" ]; then mkdir -p "$HOME/.gow"; chown -R 1000:1000 "$HOME/.gow"; fi
if [ ! -d "$HOME/.config/gow" ]; then mkdir -p "$HOME/.config/gow"; fi
if [ ! -f "$HOME/.config/gow/user.env" ]; then
echo "local_state=\"$HOME/.gow\"
TIME_ZONE=\"$(date +%Z)\"" > "$HOME/.config/gow/user.env";
fi
# Pull and Run
./run-gow --platform headless $@ pull && ./run-gow --platform headless $@ up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment