install.fairie/home/.chezmoiscripts/universal/run_onchange_after_19-gnome-extension-settings.sh.tmpl

104 lines
4.4 KiB
Cheetah
Raw Normal View History

{{- if (eq .host.distro.family "linux") -}}
#!/usr/bin/env bash
Update 55 files - /home/dot_config/rclone/system/s3-docker.service.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_07-docker-plugins.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_13-post-install-packages.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-warp.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-timeshift.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-keybase.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-install-aqua-packages.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_12-install-packages.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_15-install-asdf-packages.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_18-install-sdkman.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_19-gnome-extension-settings.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_19-theme-files.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_20-font.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_21-dconf-settings.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_45-vmware.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_46_virtualbox.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_50-crontab.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_57-netdata.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_59-connect-tailscale.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_61-plymouth-settings.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_64-grub-settings.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_70-misc-bug-fixes.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_06-bin-symlink.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_40-firefox.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_40-chrome.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_28-privoxy.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_27-tor.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_24-vpn-linux.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_26-system-vscode-node-modules.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_26-vscode-extensions.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_07-docker-plugins.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_05-log-config.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_04-environment-profile.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_11-symlink-ansible-roles.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-warp.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-timeshift.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-keybase.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_14-install-aqua-packages.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_12-install-packages.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_15-install-asdf-packages.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_18-install-sdkman.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_19-gnome-extension-settings.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_19-theme-files.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_20-font.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_21-dconf-settings.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_45-vmware.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_46_virtualbox.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_50-crontab.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_59-connect-tailscale.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_61-plymouth-settings.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_64-grub-settings.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_70-misc-bug-fixes.sh.tmpl
2023-04-11 20:26:25 -07:00
# @file GNOME Extension Settings
# @brief Applies GNOME extension settings from various data sources.
# @description
# This script ensures your GNOME extensions come pre-configured to your liking. It provides the ability
# to automatically install a configurable list of GNOME extensions as well as apply your preferred settings.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
# extension config hash: {{ include (joinPath .host.home ".config" "desktop" "gnome.yml") | sha256sum }}
### Ensure /tmp/install-gnome-extensions.txt is not present on the system
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 "$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
if [ ! -d "${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions" ]; then
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions"
fi
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 -f "$TMP_EXT" /tmp/install-gnome-extensions.txt > /dev/null
fi
done
done
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
logg info 'Running the `install-gnome-extensions` script'
cd /tmp
install-gnome-extensions --enable --overwrite --file /tmp/install-gnome-extensions.txt
rm -f /tmp/install-gnome-extensions.txt
logg success 'Finished installing the GNOME extensions'
else
logg info 'No new GNOME extensions to install'
fi
else
logg warn 'Cannot install GNOME extensions because the `install-gnome-extensions` script is missing from ~/.local/bin'
fi
### Apply plugin gsettings
if [ -f "$HOME/.config/desktop/gnome.yml" ]; then
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
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="$(cat "$TMP" | jq -r '.settings | type')"
EXT_SETTINGS="$(cat "$TMP" | jq -r '.settings')"
if [ "$EXT_SETTINGS" != 'null' ]; then
logg info 'Evaluating extension settings for `'"$EXT_ID"'`'
if [ "$EXT_SETTINGS_TYPE" == 'array' ]; then
cat "$TMP" | jq -r '.settings[]' | while read EXT_SETTING; do
logg info 'Applying following extension setting:'
echo "$EXT_SETTING"
eval "$EXT_SETTING"
done
else
logg info 'Applying following extension setting:'
echo "$EXT_SETTINGS"
eval "$EXT_SETTINGS"
fi
logg success 'Applied gsettings configuration for the `'"$EXT_ID"'` GNOME extension'
fi
done
fi
{{- end }}