|
| 1 | +#!/usr/bin/bash |
| 2 | +# based on https://github.com/ublue-os/bazzite/blob/main/system_files/desktop/shared/usr/bin/bazzite-steam |
| 3 | + |
| 4 | +DECK_OPTION="" |
| 5 | + |
| 6 | +# Nvidia crash fix |
| 7 | +export __GL_CONSTANT_FRAME_RATE_HINT=3 |
| 8 | + |
| 9 | +export COSMIC_DISABLE_DIRECT_SCANOUT=1 |
| 10 | + |
| 11 | +if [ ! -d $HOME/.local/share/Steam ]; then |
| 12 | +# Set up steam with the bootstrap before starting it, this allows steam to run for the first time even with no network access |
| 13 | + if [[ -f "/usr/share/gamescope-session-plus/bootstrap_steam.tar.gz" ]]; then |
| 14 | + mkdir -p ~/.local/share/Steam |
| 15 | + tar xf /usr/share/gamescope-session-plus/bootstrap_steam.tar.gz -C ~/.local/share/Steam |
| 16 | + fi |
| 17 | +fi |
| 18 | + |
| 19 | +# File toggle to override default Steam Deck flag behavior |
| 20 | +DECK_OVERRIDE_FLAG="$HOME/.config/cosmium/disable_steamdeck_flag" |
| 21 | + |
| 22 | +# Required to maintain the Steam update branch between desktop & Steam Game Mode |
| 23 | +if [[ ! -f "$DECK_OVERRIDE_FLAG" ]]; then |
| 24 | + DECK_OPTION="-steamdeck" |
| 25 | +else |
| 26 | + DECK_OPTION="" |
| 27 | +fi |
| 28 | + |
| 29 | +switcheroo_state="$(switcherooctl list)" |
| 30 | + |
| 31 | +# If we're running this on a dGPU in a multi-gpu AMD/Intel system, apply a workaround for the blank Steam window bug |
| 32 | +if [[ $(echo "${switcheroo_state}" | grep -o 'Device:' | wc -l) -gt 1 ]]; then |
| 33 | + # TODO: Check if -system-composer is needed with nvidia >=555 driver |
| 34 | + if ! grep -Pq 'Name:\s+NVIDIA' <<< "$switcheroo_state"; then |
| 35 | + DGPU_OPTION="-system-composer" |
| 36 | + fi |
| 37 | +fi |
| 38 | +unset -v switcheroo_state |
| 39 | + |
| 40 | +if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then |
| 41 | + # https://github.com/Supreeeme/extest |
| 42 | + # Extest is a drop in replacement for the X11 XTEST extension. |
| 43 | + # It creates a virtual device with the uinput kernel module. |
| 44 | + # It's been primarily developed for allowing the desktop functionality |
| 45 | + # on the Steam Controller to work while Steam is open on Wayland. |
| 46 | + # Also supports Steam Input as a whole. |
| 47 | + env LD_PRELOAD=/usr/lib/extest/libextest.so /usr/bin/steam "$DECK_OPTION" "$@" |
| 48 | +else |
| 49 | + /usr/bin/steam "$DECK_OPTION" "$@" |
| 50 | +fi |
0 commit comments