Update 2 files

- /home/.chezmoiscripts/universal/run_onchange_after_20-apply-settings.mjs.tmpl
- /home/.chezmoiscripts/universal/run_onchange_after_25-gnome-extension-settings.tmpl
This commit is contained in:
Brian Zalewski 2023-01-09 20:47:23 +00:00
parent 842cbb8e0e
commit bc54e851b2
2 changed files with 60 additions and 2 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env zx
// gnome config hash: {{ include (joinPath .host.home ".config" "desktop" "gnome.yml")| sha256sum }}
// settings config hash: {{ include (joinPath .host.home ".config" "desktop" "settings.yml")| sha256sum }}
// gnome config hash: {{ include (joinPath .host.home ".config" "desktop" "gnome.yml") | sha256sum }}
// settings config hash: {{ include (joinPath .host.home ".config" "desktop" "settings.yml") | sha256sum }}
{{ includeTemplate "universal/zx" }}

View file

@ -0,0 +1,58 @@
{{- if eq .host.distro.family "linux" -}}
#!/usr/bin/env bash
{{ 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
### Populate /tmp/install-gnome-extensions.txt with GNOME extensions that need to be installed
if [ -f "$HOME/.config/desktop/gnome.yml" ]; then
yq e -o=j "$HOME/.config/desktop/gnome.yml" | jq -cr '.default_gnome_extensions[]' | while read EXT; do
EXT_URL="$(echo "$EXT" | jq -r '.url')"
EXT_ID="$(echo "$EXT" | jq -r '.regex')"
echo "$EXT_URL" >> /tmp/install-gnome-extensions.txt
find "$HOME/.local/share/gnome-shell/extensions" -mindepth 1 -maxdepth 1 -type d | while read EXT_FOLDER; do
if [[ "$EXT_FOLDER" == "$EXT_REGEX"* ]]; then
head -n -1 /tmp/install-gnome-extensions.txt > "$TMP_EXT"
mv "$TMP_EXT" /tmp/install-gnome-extensions.txt
fi
done
done
else
logg warn 'The `~/.config/desktop/gnome.yml` file is missing so GNOME extension install orders cannot be calculated'
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
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'
logg info 'Restarting gnome-shell'
sudo killall -SIGQUIT gnome-shell
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
yq e -o=j "$HOME/.config/desktop/gnome.yml" | jq -cr '.default_gnome_extensions[]' | while read EXT; do
EXT_ID="$(echo "$EXT" | jq -r '.regex')"
EXT_SETTINGS="$(echo "$EXT" | jq -r '.settings')"
if [ "$EXT_SETTINGS" != 'null' ]; then
eval "$EXT_SETTINGS"
logg success 'Applied gsettings configuration for the `'"$EXT_ID"'` GNOME extension'
fi
done
fi
{{- end }}