#!/usr/bin/bash IMAGE_INFO="/usr/share/ublue-os/image-info.json" IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO) DECK_OPTION="" DISABLE_FIRSTRUN=0 # Add a flag to disable first run window for arg in "$@"; do if [[ $arg == "--disable-firstrun" ]]; then DISABLE_FIRSTRUN=1 fi done if [[ $IMAGE_NAME =~ "nvidia" ]]; then # Nvidia crash fix export __GL_CONSTANT_FRAME_RATE_HINT=3 fi # Use a dummy updater during oobe # See: https://www.reddit.com/r/Bazzite/comments/1psuar7/bazzite_xbox_ally_issue/ OOTB_DISABLE_UPDATER_OPTION="-testoobeupdater" if [[ $IMAGE_NAME =~ "deck" ]]; then if [ ! -d $HOME/.local/share/Steam ]; then # Set up steam with the bootstrap before starting it, this allows steam to run for the first time even with no network access if [[ -f "/usr/share/gamescope-session-plus/bootstrap_steam.tar.gz" ]]; then mkdir -p ~/.local/share tar xf /usr/share/gamescope-session-plus/bootstrap_steam.tar.gz -C ~/.local/share fi fi # Apply our branding for Steam if [[ -f /usr/bin/bazzite-steam-brand ]]; then /usr/bin/bazzite-steam-brand fi # File toggle to override default Steam Deck flag behavior DECK_OVERRIDE_FLAG="$HOME/.config/bazzite/disable_steamdeck_flag" # Required to maintain the Steam update branch between desktop & Steam Game Mode if [[ ! -f "$DECK_OVERRIDE_FLAG" ]]; then DECK_OPTION="-steamdeck" else DECK_OPTION="" fi else # Display a window which tells the user that Steam is about to be opened for the first time if [[ -f /usr/bin/bazzite-steam-firstrun ]] && [[ $DISABLE_FIRSTRUN -ne 1 ]]; then /usr/bin/bazzite-steam-firstrun fi fi switcheroo_state="$(switcherooctl list)" DGPU_OPTION="" # If we're running this on a dGPU in a multi-gpu AMD/Intel system, apply a workaround for the blank Steam window bug if [[ $(echo "${switcheroo_state}" | grep -o 'Device:' | wc -l) -gt 1 ]]; then # TODO: Check if -system-composer is needed with nvidia >=555 driver if ! grep -Pq 'Name:\s+NVIDIA' <<< "$switcheroo_state"; then DGPU_OPTION="-system-composer" fi fi unset -v switcheroo_state # Multithreading precaching # See: https://www.reddit.com/r/linux_gaming/comments/1j06xpz/how_to_speed_up_steams_shader_precaching/ # Use as many threads as cores minus 2, clamped between 1 and 16 STEAM_CONFIG="$HOME/.steam/steam/steam_dev.cfg" SHADER_THREAD_SETTING="unShaderBackgroundProcessingThreads" if [[ ! -f "$STEAM_CONFIG" ]] || ! grep -q "$SHADER_THREAD_SETTING" "$STEAM_CONFIG"; then threads=$(( $(nproc) - 2 )) if [[ $threads -gt 16 ]]; then threads=16 elif [[ $threads -lt 1 ]]; then threads=1 fi echo "${SHADER_THREAD_SETTING} ${threads}" >> "$STEAM_CONFIG" fi if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then # https://github.com/Supreeeme/extest # Extest is a drop in replacement for the X11 XTEST extension. # It creates a virtual device with the uinput kernel module. # It's been primarily developed for allowing the desktop functionality # on the Steam Controller to work while Steam is open on Wayland. # Also supports Steam Input as a whole. env LD_PRELOAD=/usr/lib/extest/libextest.so /usr/bin/steam "$DECK_OPTION" "$OOTB_DISABLE_UPDATER_OPTION" "$DGPU_OPTION" "$@" else /usr/bin/steam "$DECK_OPTION" "$OOTB_DISABLE_UPDATER_OPTION" "$DGPU_OPTION" "$@" fi