b955ae0945
- /home/.chezmoiscripts/universal/run_onchange_after_25-gnome-extension-settings.tmpl - /home/private_dot_config/git/template/hooks/run_after_ensure-executable.tmpl
68 lines
2.9 KiB
Cheetah
68 lines
2.9 KiB
Cheetah
{{- 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
|
|
cat "$HOME/.config/desktop/gnome.yml" | yq e -o=j '.' | 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 "$XDG_DATA_DIR/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'
|
|
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 "$HOME/.config/desktop/gnome.yml" | yq e -o=j '.' | jq -cr '.default_gnome_extensions[]' | while read EXT; do
|
|
EXT_ID="$(echo "$EXT" | jq -r '.regex')"
|
|
EXT_SETTINGS_TYPE="$(echo "$EXT" | jq -r '.settings | type')"
|
|
EXT_SETTINGS="$(echo "$EXT" | 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
|
|
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 }}
|