#!/usr/bin/env bash set -e check_command() { if ! command -v "$1" &>/dev/null; then echo "Please install \"$1\" and make sure it's available in your \$PATH, then rerun the setup." exit 1 fi } check_command "flatpak" check_command "gnome-extensions" # This script gets packaged with the release and should do the bulk of the setup work. This allows this setup to be tied # to a specific release of the code, and guarantees it will never run along-side newer or older binaries. 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 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_gnome_install" if [ -e "$XDG_BIN_HOME/breezy_gnome_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_gnome_uninstall --for-install || true UA_EVENT_NAME="breezy_gnome_update" fi 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}" mkdir -p $DATA_DIR cp manifest $DATA_DIR echo "Installing the breezydesktop@xronlinux.com GNOME extension" gnome-extensions install --force breezydesktop@xronlinux.com.shell-extension.zip echo "Installing the Breezy Desktop UI Flatpak (this may take a couple minutes the first time)" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo flatpak install --user --noninteractive --reinstall com.xronlinux.BreezyDesktop.flatpak # set up the XR driver using the local binary echo "Installing xrDriver" echo "BEGIN - xr_driver_setup" if [ -z "$1" ] then sudo bin/xr_driver_setup $(pwd)/xrDriver.tar.gz else sudo bin/xr_driver_setup -v $1 $(pwd)/xrDriver.tar.gz fi echo "END - xr_driver_setup"