From 22ef5645007e63ae0755ac08f22f77fbc72b2aad Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:09:35 -0700 Subject: [PATCH] Pull in updated driver IPC package, add nested monitor detection back in --- gnome/bin/breezy_gnome_verify | 15 ++++----------- gnome/bin/setup | 24 +++++++++++++++++++----- gnome/src/extension.js | 3 ++- ui/build-aux/start-breezy-desktop.sh | 8 ++++++++ ui/modules/PyXRLinuxDriverIPC | 2 +- ui/src/main.py | 10 +++++++--- 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/gnome/bin/breezy_gnome_verify b/gnome/bin/breezy_gnome_verify index af525ba..ee6f9b5 100755 --- a/gnome/bin/breezy_gnome_verify +++ b/gnome/bin/breezy_gnome_verify @@ -2,18 +2,11 @@ set -e -USER_HOME=$(realpath ~) - -if [ -z "$XDG_DATA_HOME" ]; then - XDG_DATA_HOME="$USER_HOME/.local/share" -fi -DATA_DIR="$XDG_DATA_HOME/breezy_gnome" - # create a string to string mapping, file name to expected file location declare -A file_paths file_paths=( - ["driver_air_glasses/manifest"]="$USER_HOME/.local/bin/xr_driver/manifest" - ["breezydesktop@xronlinux.com"]="$XDG_DATA_HOME/gnome-shell/extensions/breezydesktop@xronlinux.com" + ["xr_driver/manifest"]="{xr_driver_data_dir}/manifest" + ["breezydesktop@xronlinux.com"]="{gnome_shell_data_dir}/extensions/breezydesktop@xronlinux.com" ) # verify the file hashes in ./manifest @@ -41,9 +34,9 @@ do echo "Verification failed" >&2 exit 1 fi -done < "$XDG_DATA_HOME/breezy_gnome/manifest" +done < "{data_dir}/manifest" # if our checks succeeded, run the xr_driver verify script -$USER_HOME/.local/bin/xr_driver/verify_installation > /dev/null +{bin_dir}/xr_driver_verify > /dev/null echo "Verification succeeded" \ No newline at end of file diff --git a/gnome/bin/setup b/gnome/bin/setup index 617ae44..eb4f034 100755 --- a/gnome/bin/setup +++ b/gnome/bin/setup @@ -17,9 +17,17 @@ check_command "gnome-extensions" USER_HOME=$(realpath ~) +if [ -z "$XDG_DATA_HOME" ]; then + XDG_DATA_HOME="$USER_HOME/.local/share" +fi +XR_DRIVER_DATA_DIR="$XDG_DATA_HOME/xr_driver" +GNOME_SHELL_DATA_DIR="$XDG_DATA_HOME/gnome-shell" +DATA_DIR="$XDG_DATA_HOME/breezy_gnome" + if [ -z "$XDG_BIN_HOME" ]; then XDG_BIN_HOME="$USER_HOME/.local/bin" fi +BIN_DIR="$XDG_BIN_HOME" if [ -d "$XDG_BIN_HOME" ]; then # check ownership and permissions before doing chown and chmod @@ -36,11 +44,6 @@ if [ -d "$XDG_BIN_HOME" ]; then fi fi -if [ -z "$XDG_DATA_HOME" ]; then - XDG_DATA_HOME="$USER_HOME/.local/share" -fi -DATA_DIR="$XDG_DATA_HOME/breezy_gnome" - UA_EVENT_NAME="breezy_gnome_install" if [ -e "$XDG_BIN_HOME/breezy_gnome_uninstall" ]; then echo "Cleaning up the previous installation" @@ -55,9 +58,20 @@ UA_CLIENT_ID="BreezyGNOME" UA_EVENT_VERSION="$1" #INJECT_UA_CALL +# escaping sed replace: https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern +ESCAPED_BIN_DIR=$(printf '%s\n' "$BIN_DIR" | sed -e 's/[\/&]/\\&/g') +ESCAPED_DATA_DIR=$(printf '%s\n' "$DATA_DIR" | sed -e 's/[\/&]/\\&/g') +ESCAPED_XR_DRIVER_DATA_DIR=$(printf '%s\n' "$XR_DRIVER_DATA_DIR" | sed -e 's/[\/&]/\\&/g') +ESCAPED_GNOME_SHELL_DATA_DIR=$(printf '%s\n' "$GNOME_SHELL_DATA_DIR" | sed -e 's/[\/&]/\\&/g') + echo "Copying the breezy_gnome scripts to ${XDG_BIN_HOME}" mkdir -p $XDG_BIN_HOME cp bin/breezy_gnome_uninstall $XDG_BIN_HOME +sed -i -e "s/{bin_dir}/$ESCAPED_BIN_DIR/g" \ + -e "s/{data_dir}/$ESCAPED_DATA_DIR/g" \ + -e "s/{xr_driver_data_dir}/$ESCAPED_XR_DRIVER_DATA_DIR/g" \ + -e "s/{gnome_shell_data_dir}/$ESCAPED_GNOME_SHELL_DATA_DIR/g" \ + bin/breezy_gnome_verify cp bin/breezy_gnome_verify $XDG_BIN_HOME echo "Copying the manifest file to ${DATA_DIR}" diff --git a/gnome/src/extension.js b/gnome/src/extension.js index a7edafd..91410f7 100644 --- a/gnome/src/extension.js +++ b/gnome/src/extension.js @@ -21,7 +21,8 @@ const SUPPORTED_MONITOR_PRODUCTS = [ 'Air', 'Air 2', // guessing this one 'Air 2 Pro', - 'SmartGlasses' // TCL/RayNeo + 'SmartGlasses', // TCL/RayNeo + 'MetaMonitor' // nested mode dummy monitor ]; export default class BreezyDesktopExtension extends Extension { diff --git a/ui/build-aux/start-breezy-desktop.sh b/ui/build-aux/start-breezy-desktop.sh index b4f60b1..b82f292 100644 --- a/ui/build-aux/start-breezy-desktop.sh +++ b/ui/build-aux/start-breezy-desktop.sh @@ -5,6 +5,7 @@ IFS=: read -ra host_data_dirs < <(flatpak-spawn --host sh -c 'echo "$XDG_DATA_DIRS"') IFS=: read -ra HOST_XDG_STATE_HOME < <(flatpak-spawn --host sh -c 'echo "$XDG_STATE_HOME"') +IFS=: read -ra HOST_XDG_CONFIG_HOME < <(flatpak-spawn --host sh -c 'echo "$XDG_CONFIG_HOME"') IFS=: read -ra HOST_XDG_BIN_HOME < <(flatpak-spawn --host sh -c 'echo "$XDG_BIN_HOME"') IFS=: read -ra HOST_XDG_DATA_HOME < <(flatpak-spawn --host sh -c 'echo "$XDG_DATA_HOME"') @@ -48,6 +49,12 @@ else XDG_STATE_HOME="$(realpath ~)/.local/state" fi +if [[ ! -z "${HOST_XDG_CONFIG_HOME}" ]]; then + XDG_CONFIG_HOME="${HOST_XDG_CONFIG_HOME}" +else + XDG_CONFIG_HOME="$(realpath ~)/.config" +fi + if [[ ! -z "${HOST_XDG_DATA_HOME}" ]]; then XDG_DATA_HOME="${HOST_XDG_DATA_HOME}" else @@ -57,5 +64,6 @@ fi export XDG_DATA_DIRS export XDG_BIN_HOME export XDG_STATE_HOME +export XDG_CONFIG_HOME export XDG_DATA_HOME exec breezydesktop "$@" \ No newline at end of file diff --git a/ui/modules/PyXRLinuxDriverIPC b/ui/modules/PyXRLinuxDriverIPC index 34a349d..a96fdeb 160000 --- a/ui/modules/PyXRLinuxDriverIPC +++ b/ui/modules/PyXRLinuxDriverIPC @@ -1 +1 @@ -Subproject commit 34a349d39efc02f4b65550debd193d29d95a84f9 +Subproject commit a96fdeb1557d8cd24e73cb8e9e2559adfa46e3aa diff --git a/ui/src/main.py b/ui/src/main.py index 8781f21..6ab6068 100644 --- a/ui/src/main.py +++ b/ui/src/main.py @@ -36,8 +36,12 @@ from .statemanager import StateManager from .window import BreezydesktopWindow from .xrdriveripc import XRDriverIPC -state_dir = os.path.expanduser("~/.local/state") -log_dir = os.path.join(state_dir, 'breezy_gnome/logs/ui') +config_home = os.environ.get('XDG_CONFIG_HOME', '~/.config') +config_dir = os.path.expanduser(config_home) +state_home = os.environ.get('XDG_STATE_HOME', '~/.local/state') +state_dir = os.path.expanduser(state_home) +breezy_state_dir = os.path.join(state_dir, 'breezy_gnome') +log_dir = os.path.join(breezy_state_dir, 'logs/ui') os.makedirs(log_dir, exist_ok=True) logger = logging.getLogger('breezy_ui') @@ -54,7 +58,7 @@ def excepthook(exc_type, exc_value, exc_traceback): sys.excepthook = excepthook -XRDriverIPC.set_instance(XRDriverIPC(logger)) +XRDriverIPC.set_instance(XRDriverIPC(logger, config_dir)) class BreezydesktopApplication(Adw.Application): """The main application singleton class."""