diff --git a/.config/WindowsAutoNightMode/scripts.yaml b/.config/WindowsAutoNightMode/scripts.yaml index b45088b..eb4ad9f 100644 --- a/.config/WindowsAutoNightMode/scripts.yaml +++ b/.config/WindowsAutoNightMode/scripts.yaml @@ -4,22 +4,7 @@ Component: - Name: WSL Theming Command: bash WorkingDirectory: C:\Users\anri\AppData\Roaming\AutoDarkMode - ArgsLight: [ - -c, - "fish -c \" \ - fish_config theme choose 'Solarized Light' && yes | fish_config theme save\" && \ - sed -i 's/monokai/bubblegum/g' ~/.config/micro/settings.json && \ - sed -i 's/#color = \"default\"/color = \"default-light\"/g' ~/.config/bottom/bottom.toml && \ - sed -i 's/Dracula/Solarized (light)/g' ~/.config/bat/config", - ] - ArgsDark: [ - -c, - "fish -c \" \ - fish_config theme choose 'Base16 Eighties' && yes | fish_config theme save && \ - set fish_color_comment 5c6773\" && \ - sed -i 's/bubblegum/monokai/g' ~/.config/micro/settings.json && \ - sed -i 's/color = \"default-light\"/#color = \"default\"/g' ~/.config/bottom/bottom.toml && \ - sed -i 's/Solarized (light)/Dracula/g' ~/.config/bat/config", - ] + ArgsLight: [-c, "fish -c 'update-theme light'"] + ArgsDark: [-c, "fish -c 'update-theme dark'"] AllowedSources: [Any] TimeoutMillis: diff --git a/.config/fish/functions/update-theme.fish b/.config/fish/functions/update-theme.fish new file mode 100644 index 0000000..0128408 --- /dev/null +++ b/.config/fish/functions/update-theme.fish @@ -0,0 +1,56 @@ +function update-theme --description "Update the shell theme." + # Declare our arguments + argparse h/help -- $argv + or return + + # Get function name + set current_name $(status current-function) + + # Check if no arguments were provided, or if the first argument is '--help' + if test -z $argv[1] || set -ql _flag_help + echo -e "Usage: $current_name light|dark" + echo -e " $current_name [-h|--help] \t- Show this help message" + echo -e " $current_name light \t\t- Go to light mode" + echo -e " $current_name dark \t\t- Go to dark mode" + return 0 + end + + set theme "$argv[1]" + + if test (count $argv) -ge 2 + # Check if usage is respected + echo "$current_name: too much arguments." 1>&2 + return 1 + end + + switch $theme + case "light" + # Fish theme + fish_config theme choose "Solarized Light" && yes | fish_config theme save + + # Micro editor + sed -i "s/monokai/bubblegum/g" "$HOME"/.config/micro/settings.json + + # Bottom theme + sed -i "s/#color = \"default\"/color = \"default-light\"/g" "$HOME"/.config/bottom/bottom.toml + + # Bat theme + sed -i "s/Dracula/Solarized (light)/g" "$HOME"/.config/bat/config + case "dark" + # Fish theme + fish_config theme choose "Base16 Eighties" && yes | fish_config theme save + set fish_color_comment 5c6773 # custom comment color + + # Micro editor + sed -i "s/bubblegum/monokai/g" "$HOME"/.config/micro/settings.json + + # Bottom theme + sed -i "s/color = \"default-light\"/#color = \"default\"/g" "$HOME"/.config/bottom/bottom.toml + + # Bat theme + sed -i "s/Solarized (light)/Dracula/g" "$HOME"/.config/bat/config + case "*" + echo "$current_name: unknown theme." 1>&2 + return 1 + end +end diff --git a/.config/update_theme.sh b/.config/update_theme.sh index eb85368..59071a1 100755 --- a/.config/update_theme.sh +++ b/.config/update_theme.sh @@ -27,24 +27,13 @@ main() { gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ \ background-color "rgb(45,45,45)" - # Fish theme - fish -c "fish_config theme choose 'Base16 Eighties' && \ - yes | fish_config theme save" - fish -c "set fish_color_comment 5c6773" # custom comment color - - # Micro editor - sed -i "s/bubblegum/monokai/g" "$HOME"/.config/micro/settings.json + # Shell theme + fish -c "update-theme dark" # Keyboard backlight busctl call --system org.freedesktop.UPower \ /org/freedesktop/UPower/KbdBacklight \ org.freedesktop.UPower.KbdBacklight SetBrightness 'i' 1 - - # Bottom theme - sed -i "s/color = \"default-light\"/#color = \"default\"/g" "$HOME"/.config/bottom/bottom.toml - - # Bat theme - sed -i "s/Solarized (light)/Dracula/g" "$HOME"/.config/bat/config ;; @@ -57,23 +46,14 @@ main() { gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${GT_default}"/ \ background-color "rgb(253,246,227)" - # Fish theme - fish -c "fish_config theme choose 'Solarized Light' && yes | fish_config theme save" - - # Micro editor - sed -i "s/monokai/bubblegum/g" "$HOME"/.config/micro/settings.json + # Shell theme + fish -c "update-theme light" # Keyboard backlight busctl call --system org.freedesktop.UPower \ /org/freedesktop/UPower/KbdBacklight \ org.freedesktop.UPower.KbdBacklight SetBrightness 'i' 0 - # Bottom theme - sed -i "s/#color = \"default\"/color = \"default-light\"/g" "$HOME"/.config/bottom/bottom.toml - - # Bat theme - sed -i "s/Dracula/Solarized (light)/g" "$HOME"/.config/bat/config - # Gnome fix theme TODO: Is this necessary? need some research gsettings set org.gnome.desktop.interface color-scheme 'prefer-light' ;; diff --git a/Makefile b/Makefile index d50179d..c307a08 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ sync-dotconfig: @$(WGET) $(REPO_SRC)/.config/fish/functions/ssh-import.fish -O $(HOME)/.config/fish/functions/ssh-import.fish @$(WGET) $(REPO_SRC)/.config/fish/functions/ugc.fish -O $(HOME)/.config/fish/functions/ugc.fish @$(WGET) $(REPO_SRC)/.config/fish/functions/catall.fish -O $(HOME)/.config/fish/functions/catall.fish + @$(WGET) $(REPO_SRC)/.config/fish/functions/update-theme.fish -O $(HOME)/.config/fish/functions/update-theme.fish @$(WGET) $(REPO_SRC)/.config/fish/conf.d/abbr.fish -O $(HOME)/.config/fish/conf.d/abbr.fish @$(WGET) $(REPO_SRC)/.config/fish/conf.d/alias.fish -O $(HOME)/.config/fish/conf.d/alias.fish