264 lines
7.7 KiB
Bash
Executable File
264 lines
7.7 KiB
Bash
Executable File
#!/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" <<EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Enable Breezy Wayland
|
|
Comment=Enable Wayland for Breezy Desktop virtual displays
|
|
Exec=$enable_script
|
|
Icon=com.xronlinux.BreezyDesktop
|
|
Categories=Utility;
|
|
Terminal=false
|
|
StartupNotify=false
|
|
EOF
|
|
|
|
cat > "$disable_desktop" <<EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Disable Breezy Wayland
|
|
Comment=Disable Wayland, allow return to Game Mode
|
|
Exec=$disable_script
|
|
Icon=com.xronlinux.BreezyDesktop
|
|
Categories=Utility;
|
|
Terminal=false
|
|
StartupNotify=false
|
|
EOF
|
|
|
|
chmod 644 "$enable_desktop" "$disable_desktop"
|
|
command cp "$enable_desktop" "$desktop_enable"
|
|
command cp "$disable_desktop" "$desktop_disable"
|
|
chmod 755 "$desktop_enable" "$desktop_disable"
|
|
|
|
echo "Installed SteamOS desktop shortcuts in $applications_dir and on $desktop_dir"
|
|
}
|
|
|
|
USER_HOME=$(realpath ~)
|
|
|
|
if [ -z "$XDG_DATA_HOME" ]; then
|
|
XDG_DATA_HOME="$USER_HOME/.local/share"
|
|
fi
|
|
|
|
fix_xr_gaming_plugin() {
|
|
# Allows the plugin and Breezy Desktop to coexist without fighting over the driver version
|
|
local breezy_manifest="$XDG_DATA_HOME/breezy_vulkan/manifest"
|
|
if [[ ! -f "$breezy_manifest" ]]; then
|
|
return 0
|
|
fi
|
|
|
|
local decky_xr_gaming_settings="$USER_HOME/homebrew/settings/decky-XRGaming/settings.json"
|
|
if [[ ! -f "$decky_xr_gaming_settings" ]]; then
|
|
return 0
|
|
fi
|
|
|
|
local xr_driver_manifest="$XDG_DATA_HOME/xr_driver/manifest"
|
|
if [[ ! -f "$xr_driver_manifest" ]]; then
|
|
return 0
|
|
fi
|
|
|
|
local XR_DRIVER_MANIFEST_LINE
|
|
XR_DRIVER_MANIFEST_LINE=$(sha256sum "$xr_driver_manifest")
|
|
|
|
local xr_driver_manifest_hash
|
|
xr_driver_manifest_hash="${XR_DRIVER_MANIFEST_LINE%% *}"
|
|
if [[ -z "$xr_driver_manifest_hash" ]]; then
|
|
return 0
|
|
fi
|
|
|
|
echo "Fixing XR Gaming plugin installation"
|
|
|
|
local tmp_manifest
|
|
tmp_manifest=$(mktemp)
|
|
sed '/xr_driver\/manifest$/d' "$breezy_manifest" > "$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" <<EOF
|
|
|
|
# Added by Breezy Desktop installer: QT plugin path setup
|
|
$QT_PLUGIN_EXPORT
|
|
EOF
|
|
fi
|
|
|
|
PLASMA_ENV_SCRIPT="$HOME/.config/plasma-workspace/env/breezy_desktop.sh"
|
|
if [[ ! -f "$PLASMA_ENV_SCRIPT" ]]; then
|
|
echo "Adding QT_PLUGIN_PATH to $PLASMA_ENV_SCRIPT"
|
|
mkdir -p "$(dirname "$PLASMA_ENV_SCRIPT")"
|
|
cat >> "$PLASMA_ENV_SCRIPT" <<EOF
|
|
|
|
# Added by Breezy Desktop installer: QT plugin path setup
|
|
$QT_PLUGIN_EXPORT
|
|
EOF
|
|
fi
|
|
|
|
# set up the XR driver using the local binary
|
|
echo "Installing xrDriver (requires sudo)"
|
|
echo "BEGIN - xr_driver_setup"
|
|
if [ -z "$1" ]
|
|
then
|
|
sudo bin/xr_driver_setup $(pwd)
|
|
else
|
|
sudo bin/xr_driver_setup -v $1 $(pwd)
|
|
fi
|
|
|
|
echo "END - xr_driver_setup"
|
|
|
|
fix_xr_gaming_plugin
|
|
|
|
echo "Setting up productivity features"
|
|
printf "request_features=productivity_basic\n" >> /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" |