#!/usr/bin/env bash set -e if [ "$XDG_SESSION_TYPE" != "wayland" ]; then printf "\033[1;33mWARNING:\033[0m Windowing system is %s\n" "$XDG_SESSION_TYPE" printf "\033[1;33mWARNING:\033[0m Virtual display functionality requires Wayland\n" fi install_steamos_shortcuts() { local os_release="/etc/os-release" if [[ ! -r "$os_release" ]]; then return fi local ID="" local ID_LIKE="" # shellcheck disable=SC1090 source "$os_release" if [[ "$ID" != "steamos" && "$ID_LIKE" != *"steamos"* && "$ID_LIKE" != *"steamdeck"* ]]; then return fi if ! command -v steamos-session-select >/dev/null 2>&1; then echo "Skipping SteamOS shortcuts: steamos-session-select not found" return fi local applications_dir="$HOME/.local/share/applications" local desktop_dir="$HOME/Desktop" local enable_script="$XDG_BIN_HOME/breezy_enable_wayland" local disable_script="$XDG_BIN_HOME/breezy_disable_wayland" local enable_desktop="$applications_dir/Enable Breezy Wayland.desktop" local disable_desktop="$applications_dir/Disable Breezy Wayland.desktop" local desktop_enable="$desktop_dir/Enable Breezy Wayland.desktop" local desktop_disable="$desktop_dir/Disable Breezy Wayland.desktop" mkdir -p "$applications_dir" "$desktop_dir" cat > "$enable_script" <<'EOF' #!/usr/bin/env bash set -e MESSAGE="IMPORTANT - You will be unable to return to Game Mode until you use the Disable Breezy Wayland script." if command -v kdialog >/dev/null 2>&1; then if ! kdialog --warningyesno "$MESSAGE" --title "Enable Breezy Wayland" --yes-label "Enable" --no-label "Cancel"; then exit 0 fi elif command -v zenity >/dev/null 2>&1; then if ! zenity --question --title="Enable Breezy Wayland" --text="$MESSAGE" --ok-label="Enable" --cancel-label="Cancel" --no-wrap; then exit 0 fi else echo "$MESSAGE" read -r -p "Type 'enable' to continue: " confirmation if [[ "$confirmation" != "enable" ]]; then exit 0 fi fi exec steamos-session-select plasma-wayland-persistent EOF cat > "$disable_script" <<'EOF' #!/usr/bin/env bash set -e exec steamos-session-select EOF chmod +x "$enable_script" "$disable_script" cat > "$enable_desktop" < "$disable_desktop" < "$tmp_manifest" printf '%s xr_driver/manifest\n' "$xr_driver_manifest_hash" >> "$tmp_manifest" chmod --reference="$breezy_manifest" "$tmp_manifest" 2>/dev/null || true mv "$tmp_manifest" "$breezy_manifest" local breezy_manifest_hash breezy_manifest_hash="$(sha256sum "$breezy_manifest" | awk '{print $1}')" if [[ -z "$breezy_manifest_hash" ]]; then return 0 fi local settings_dir settings_dir="$(dirname "$decky_xr_gaming_settings")" local tmp_settings tmp_settings="$(mktemp -p "$settings_dir" settings.XXXXXX)" sed -E 's/("manifest_checksum"[[:space:]]*:[[:space:]]*")[^"]*(")/\1'"$breezy_manifest_hash"'\2/' "$decky_xr_gaming_settings" > "$tmp_settings" chmod --reference="$decky_xr_gaming_settings" "$tmp_settings" 2>/dev/null || true mv "$tmp_settings" "$decky_xr_gaming_settings" } if [ -z "$XDG_BIN_HOME" ]; then XDG_BIN_HOME="$USER_HOME/.local/bin" fi if [ -d "$XDG_BIN_HOME" ]; then # check ownership and permissions before doing chown and chmod XDG_BIN_USER=$(stat -c %U $XDG_BIN_HOME) XDG_BIN_GROUP=$(stat -c %G $XDG_BIN_HOME) USER=$(whoami) GROUP=$(id -gn) if [ "$XDG_BIN_USER" != "$USER" ] || [ "$XDG_BIN_GROUP" != "$GROUP" ]; then echo "Fixing ownership and permissions of $XDG_BIN_HOME" sudo chown -R $USER:$GROUP $XDG_BIN_HOME sudo chmod -R 700 $XDG_BIN_HOME fi fi UA_EVENT_NAME="breezy_kwin_install" if [ -e "$XDG_BIN_HOME/breezy_kwin_uninstall" ]; then echo "Cleaning up the previous installation" # ` || true` will ensure that this can't cause a failure, even with `set -e` $XDG_BIN_HOME/breezy_kwin_uninstall --for-install || true UA_EVENT_NAME="breezy_kwin_update" fi UA_CLIENT_ID="BreezyKWin" UA_EVENT_VERSION="$1" #INJECT_UA_CALL tar -xf $(pwd)/breezyKWinPlugin.tar.gz pushd breezy_desktop/usr > /dev/null echo "Copying KWin plugin files to $USER_HOME/.local/{lib,share}" # locate the lib path that ends with qt6/plugins (handles multiarch dirs) QT_PLUGIN_DIR_RELATIVE=$(find lib* -type d -path '*/qt6/plugins' -print -quit 2>/dev/null || true) if [ -z "$QT_PLUGIN_DIR_RELATIVE" ]; then QT_PLUGIN_DIR_RELATIVE="lib/qt6/plugins" fi # directory structure matches XDG, so just recursive copy chmod -R 755 . cp -r . "$USER_HOME/.local/" popd > /dev/null mkdir -p $XDG_BIN_HOME cp bin/breezy_kwin_uninstall $XDG_BIN_HOME cp bin/breezy_kwin_logs $XDG_BIN_HOME install_steamos_shortcuts # Install QT_PLUGIN_PATH snippet into ~/.bash_profile if not present BASH_PROFILE="$HOME/.bash_profile" QT_PLUGIN_DIR="$HOME/.local/$QT_PLUGIN_DIR_RELATIVE" QT_PLUGIN_EXPORT="export QT_PLUGIN_PATH=\"$QT_PLUGIN_DIR:\$QT_PLUGIN_PATH\"" if [[ ! -f "$BASH_PROFILE" ]] || ! grep -Fq "$QT_PLUGIN_EXPORT" "$BASH_PROFILE" 2>/dev/null; then echo "Adding QT_PLUGIN_PATH to $BASH_PROFILE" mkdir -p "$(dirname "$BASH_PROFILE")" cat >> "$BASH_PROFILE" <> "$PLASMA_ENV_SCRIPT" <> /dev/shm/xr_driver_control 2>/dev/null || true printf "\n\033[1;33m!!! IMPORTANT !!!\033[0m You must log out and back in, then enable Breezy Desktop from the Desktop Effects in System Settings\n\n"