diff --git a/home/.chezmoiscripts/universal/run_onchange_after_25-gnome-extension-settings.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_25-gnome-extension-settings.tmpl index 06a24ff7..70de3164 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_25-gnome-extension-settings.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_25-gnome-extension-settings.tmpl @@ -11,16 +11,25 @@ if [ -f /tmp/install-gnome-extensions.txt ]; then rm -f /tmp/install-gnome-extensions.txt fi +### Register temporary file for gnome.yml JSON +if [ -f "$HOME/.config/desktop/gnome.yml" ]; then + TMP_YQ="$(mktemp)" + cat "$HOME/.config/desktop/gnome.yml" | yq e -o=j '.' > "$TMP_YQ" +fi + ### Populate /tmp/install-gnome-extensions.txt with GNOME extensions that need to be installed if [ -f "$HOME/.config/desktop/gnome.yml" ]; then - cat "$HOME/.config/desktop/gnome.yml" | yq e -o=j '.' | jq -cr '.default_gnome_extensions[] | tojson' | while read EXT; do - EXT_URL="$(echo "$EXT" | jq -r '.url')" - EXT_ID="$(echo "$EXT" | jq -r '.regex')" + cat "$TMP_YQ" | jq -c '.default_gnome_extensions[] | tojson' | while read EXT; do + TMP="$(mktemp)" + echo "$EXT" | sed 's/^.\(.*\).$/\1/' > "$TMP" + EXT_URL="$(cat "$TMP" | jq -r '.url')" + EXT_ID="$(cat "$TMP" | jq -r '.regex')" echo "$EXT_URL" >> /tmp/install-gnome-extensions.txt - find "$XDG_DATA_DIR/gnome-shell/extensions" -mindepth 1 -maxdepth 1 -type d | while read EXT_FOLDER; do - if [[ "$EXT_FOLDER" == "$EXT_REGEX"* ]]; then + find "${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions" -mindepth 1 -maxdepth 1 -type d | while read EXT_FOLDER; do + if [[ "$EXT_FOLDER" == *"$EXT_ID"* ]] && [ -f /tmp/install-gnome-extensions.txt ]; then + TMP_EXT="$(mktemp)" head -n -1 /tmp/install-gnome-extensions.txt > "$TMP_EXT" - mv "$TMP_EXT" /tmp/install-gnome-extensions.txt + mv -f "$TMP_EXT" /tmp/install-gnome-extensions.txt > /dev/null fi done done @@ -28,6 +37,11 @@ else logg warn 'The `~/.config/desktop/gnome.yml` file is missing so GNOME extension install orders cannot be calculated' fi +### Remove /tmp/install-gnome-extensions.txt if it is empty +if [ "$(cat /tmp/install-gnome-extensions.txt)" == "" ]; then + rm -f /tmp/install-gnome-extensions.txt > /dev/null +fi + ### Install the GNOME extensions using the `install-gnome-extensions` script if command -v install-gnome-extensions > /dev/null; then if [ -f /tmp/install-gnome-extensions.txt ]; then @@ -43,22 +57,25 @@ fi ### Apply plugin gsettings if [ -f "$HOME/.config/desktop/gnome.yml" ]; then - cat "$HOME/.config/desktop/gnome.yml" | yq e -o=j '.' | jq -cr '.default_gnome_extensions[] | tojson' | while read EXT; do + cat "$TMP_YQ" | jq -c '.default_gnome_extensions[] | tojson' | while read EXT; do if [ "$DEBUG_MODE" == 'true' ]; then logg info 'Extension data:' echo "$EXT" fi - EXT_ID="$(echo "$EXT" | jq -r '.regex')" + TMP="$(mktemp)" + echo "$EXT" | sed 's/^.\(.*\).$/\1/' > "$TMP" + EXT_URL="$(cat "$TMP" | jq -r '.url')" + EXT_ID="$(cat "$TMP" | jq -r '.regex')" if [ "$DEBUG_MODE" == 'true' ]; then logg info 'Extension ID:' echo "$EXT_ID" fi - EXT_SETTINGS_TYPE="$(echo "$EXT" | jq -r '.settings | type')" - EXT_SETTINGS="$(echo "$EXT" | jq -r '.settings')" + EXT_SETTINGS_TYPE="$(cat "$TMP" | jq -r '.settings | type')" + EXT_SETTINGS="$(cat "$TMP" | jq -r '.settings')" if [ "$EXT_SETTINGS" != 'null' ]; then logg info 'Evaluating extension settings' if [ "$EXT_SETTINGS_TYPE" == 'array' ]; then - echo "$EXT_SETTINGS" | jq -cr '.[]' | while read EXT_SETTING; do + cat "$TMP" | jq -r '.settings[]' | while read EXT_SETTING; do logg info 'Applying following extension setting:' echo "$EXT_SETTING" eval "$EXT_SETTING" diff --git a/home/.chezmoiscripts/universal/run_onchange_after_70-misc-bug-fixes.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_70-misc-bug-fixes.tmpl index 4f70f578..31b106e8 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_70-misc-bug-fixes.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_70-misc-bug-fixes.tmpl @@ -31,12 +31,12 @@ fi ### Move ~/.gnome/apps/* to ~/.local/share/applications if [ -d "$HOME/gnome/apps" ]; then - if [ ! -d "${XDG_DATA_DIR:-$HOME/.local/share}/applications" ]; then - mkdir -p "${XDG_DATA_DIR:-$HOME/.local/share}/applications" + if [ ! -d "${XDG_DATA_HOME:-$HOME/.local/share}/applications" ]; then + mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications" fi find "$HOME/gnome/apps" -mindepth 1 -maxdepth 1 -type f | while read DESKTOP_FILE; do - logg info "Moving $DESKTOP_FILE to ${XDG_DATA_DIR:-$HOME/.local/share}/applications/$(basename "$DESKTOP_FILE")" - mv "$DESKTOP_FILE" "${XDG_DATA_DIR:-$HOME/.local/share}/applications/$(basename "$DESKTOP_FILE")" + logg info "Moving $DESKTOP_FILE to ${XDG_DATA_HOME:-$HOME/.local/share}/applications/$(basename "$DESKTOP_FILE")" + mv "$DESKTOP_FILE" "${XDG_DATA_HOME:-$HOME/.local/share}/applications/$(basename "$DESKTOP_FILE")" done logg info 'Removing ~/.gnome/apps' rm -rf "$HOME/.gnome/apps" diff --git a/software.yml b/software.yml index 9d5fd253..f06e31fb 100644 --- a/software.yml +++ b/software.yml @@ -6886,8 +6886,8 @@ softwarePackages: # brew: vectordotdev/brew/vector helm: https://helm.vector.dev pacman: vector - script:darwin: curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | bash -s -- --prefix "${XDG_DATA_DIR:-$HOME/.local/share}/vector" --no-modify-path -y - script:linux: curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | bash -s -- --prefix "${XDG_DATA_DIR:-$HOME/.local/share}/vector" --no-modify-path -y + script:darwin: curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | bash -s -- --prefix "${XDG_DATA_HOME:-$HOME/.local/share}/vector" --no-modify-path -y + script:linux: curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | bash -s -- --prefix "${XDG_DATA_HOME:-$HOME/.local/share}/vector" --no-modify-path -y velero: _bin: velero _desc: null