From 14b3872e32d043c0d7adc96e245dd8045854cd16 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sat, 24 Feb 2024 12:16:49 -0500 Subject: [PATCH] Add load/push-extensions for gnome --- fake_home/.zshrc | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 4f91a93..91c3b01 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -109,21 +109,53 @@ function push-dconf { echo "An alias for scpace has not been defined on this device!" return 1 fi - rm /tmp/dconf-dump &> /dev/null dconf-dump > /tmp/dconf-dump || return 1 scp -P 11275 /tmp/dconf-dump 'sage@sagev.space:~/dconf-dump' } +function push-extensions { + if ! command -v gnome-extensions &> /dev/null; then + echo "gnome-extensions is not installed!" + return + fi + gnome-extensions list > /tmp/gnome-extension-list + scp -P 11275 /tmp/gnome-extension-list 'sage@sagev.space:~/gnome-extension-list' +} + +function load-extensions { + if ! command -v gnome-extensions &> /dev/null; then + echo "gnome-extensions is not installed!" + return + fi + local existing="$(gnome-extensions list)" + for ext in $(cat /tmp/gnome-extension-list); do + if grep "$ext" <(echo $existing) &> /dev/null; then + continue + fi + VERSION_TAG=$(curl -Lfs "https://extensions.gnome.org/extension-query/?search=${ext}" | jq '.extensions[0] | .shell_version_map | map(.pk) | max') + wget -O ${ext}.zip "https://extensions.gnome.org/download-extension/${ext}.shell-extension.zip?version_tag=$VERSION_TAG" + gnome-extensions install --force ${EXTENSION_ID}.zip + if ! gnome-extensions list | grep --quiet ${ext}; then + busctl --user call org.gnome.Shell.Extensions /org/gnome/Shell/Extensions org.gnome.Shell.Extensions InstallRemoteExtension s ${ext} + fi + gnome-extensions enable ${ext} + rm ${EXTENSION_ID}.zip + done +} + function pushdot { cd "$DOT_DIR" || return 1 local res if [ $# -eq 0 ]; then - git commit -a && git push -u origin main && push-dconf + git commit -a res="$?" else - git commit -a -m "$@" && git push -u origin main && push-dconf + git commit -a -m "$@" res="$?" fi + if [[ "$res" == "0" ]]; then + git push -u origin main && push-extensions && push-dconf + fi cd - return $res } @@ -136,6 +168,8 @@ function getdot { cd "$DOT_DIR" || return 1 git pull && ./copy.sh rm /tmp/dconf-dump &> /dev/null + scp -P 11275 'sage@sagev.space:~/gnome-extension-list' /tmp/gnome-extension-list + load-extensions scp -P 11275 'sage@sagev.space:~/dconf-dump' /tmp/dconf-dump dconf-dump > /tmp/current-dconf-dump if ! git --no-pager diff --no-index /tmp/current-dconf-dump /tmp/dconf-dump &> /dev/null; then