From 6df2a46612d13e1535a151f047a9f090457eaf24 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 13 Sep 2023 14:22:11 +0200 Subject: [PATCH] Hot-reload terminal theme --- .config/update_theme.sh | 12 ++++++++---- arch.sh | 17 ++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.config/update_theme.sh b/.config/update_theme.sh index 70381d1..5f46baf 100755 --- a/.config/update_theme.sh +++ b/.config/update_theme.sh @@ -15,20 +15,24 @@ main() { if [ $# -eq 0 ]; then echo "No arguments supplied" else - local profiles - IFS=" " read -r -a profiles <<< "$(gsettings get org.gnome.Terminal.ProfilesList list | tr -d "\'[],")" + local GT_default + GT_default=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \') case $1 in "sunset" ) # Go to dark mode # Set the Dracula theme set org.gnome.desktop.wm.preferences theme Dracula # Set the Terminal profile - gsettings set org.gnome.Terminal.ProfilesList default "${profiles[0]}" + gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ visible-name 'Dark' + gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ foreground-color "rgb(211,208,200)" + gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ background-color "rgb(45,45,45)" # Set the fish theme fish -c "fish_config theme choose 'Base16 Eighties' && yes | fish_config theme save" ;; "sunrise" ) # Go to light mode # Set the Terminal profile - gsettings set org.gnome.Terminal.ProfilesList default "${profiles[1]}" + gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ visible-name 'Light' + gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ foreground-color "rgb(23,20,33)" + gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ background-color "rgb(253,246,227)" # Set the fish theme fish -c "fish_config theme choose 'Solarized Light' && yes | fish_config theme save" ;; diff --git a/arch.sh b/arch.sh index 2ba0a46..d55e836 100644 --- a/arch.sh +++ b/arch.sh @@ -96,11 +96,12 @@ main() { wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/alias.fish -O "$HOME"/.config/fish/conf.d/alias.fish # Themes in Gnome Terminal, the default one will be the dark one - local GT_default GT_light + local GT_default GT_profile2 GT_default=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d \') - GT_light=$(uuidgen) - gsettings set org.gnome.Terminal.ProfilesList list "['${GT_default}', '${GT_light}']" - GT_profiles=("${GT_default}" "${GT_light}") + GT_profile2=$(uuidgen) + gsettings set org.gnome.Terminal.ProfilesList list "['${GT_default}', '${GT_profile2}']" + GT_profiles=("${GT_default}" "${GT_profile2}") + wget -q https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/update_theme.sh -P "$HOME"/.config/ for profile in "${GT_profiles[@]}" do gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${profile}"/ use-custom-command true @@ -114,13 +115,7 @@ main() { gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${profile}"/ font "MesloLGM Nerd Font 12" gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${profile}"/ use-system-font false done - # Dark theme - gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ visible-name 'Dark' - gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ foreground-color "rgb(211,208,200)" - gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ background-color "rgb(45,45,45)" - # Light theme - gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_light}"/ visible-name 'Light' - gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_light}"/ background-color "rgb(253,246,227)" + bash "$HOME"/.config/update_theme.sh sunset # Keybinds gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ close-tab "w"