diff --git a/bin/omakub-sub/theme.sh b/bin/omakub-sub/theme.sh index 1a786de66..8431e94ea 100644 --- a/bin/omakub-sub/theme.sh +++ b/bin/omakub-sub/theme.sh @@ -3,22 +3,31 @@ THEME_NAMES=("Tokyo Night" "Catppuccin" "Nord" "Everforest" "Gruvbox" "Kanagawa" "Ristretto" "Rose Pine" "Matte Black") THEME=$(gum choose "${THEME_NAMES[@]}" "<< Back" --header "Choose your theme" --height 12 | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g') +CONFIG_THEMES_PATH="$HOME/.config/omakub/themes/" +CONFIG_CURRENT_THEME_PATH="$HOME/.config/omakub/current/theme" + if [ -n "$THEME" ] && [ "$THEME" != "<<-back" ]; then - cp $OMAKUB_PATH/themes/$THEME/alacritty.toml ~/.config/alacritty/theme.toml - cp $OMAKUB_PATH/themes/$THEME/zellij.kdl ~/.config/zellij/themes/$THEME.kdl + #Create the symlink from the new theme to our current theme + ln -snf $CONFIG_THEMES_PATH/$THEME $CONFIG_CURRENT_THEME_PATH + + # Set specific app links for current theme + ln -snf $CONFIG_CURRENT_THEME_PATH/alacritty.toml ~/.config/alacritty/theme.toml + + ln -snf $CONFIG_CURRENT_THEME_PATH/zellij.kdl ~/.config/zellij/themes/$THEME.kdl sed -i "s/theme \".*\"/theme \"$THEME\"/g" ~/.config/zellij/config.kdl - cp $OMAKUB_PATH/themes/$THEME/neovim.lua ~/.config/nvim/lua/plugins/theme.lua - if [ -f "$OMAKUB_PATH/themes/$THEME/btop.theme" ]; then - cp $OMAKUB_PATH/themes/$THEME/btop.theme ~/.config/btop/themes/$THEME.theme + ln -snf $CONFIG_CURRENT_THEME_PATH/neovim.lua ~/.config/nvim/lua/plugins/theme.lua + + if [ -f "$CONFIG_CURRENT_THEME_PATH/btop.theme" ]; then + ln -snf $CONFIG_CURRENT_THEME_PATH/btop.theme ~/.config/btop/themes/$THEME.theme sed -i "s/color_theme = \".*\"/color_theme = \"$THEME\"/g" ~/.config/btop/btop.conf else sed -i "s/color_theme = \".*\"/color_theme = \"Default\"/g" ~/.config/btop/btop.conf fi - source $OMAKUB_PATH/themes/$THEME/gnome.sh - source $OMAKUB_PATH/themes/$THEME/tophat.sh - source $OMAKUB_PATH/themes/$THEME/vscode.sh + source $CONFIG_CURRENT_THEME_PATH/gnome.sh + source $CONFIG_CURRENT_THEME_PATH/tophat.sh + source $CONFIG_CURRENT_THEME_PATH/vscode.sh # Forgo setting the Chrome theme until we might find a less disruptive way of doing it. # Having to quit Chrome, and all Chrome-based apps, is too much of an inposition. diff --git a/install/desktop/set-gnome-theme.sh b/install/desktop/set-gnome-theme.sh deleted file mode 100644 index 2b267e409..000000000 --- a/install/desktop/set-gnome-theme.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -source ~/.local/share/omakub/themes/tokyo-night/gnome.sh -source ~/.local/share/omakub/themes/tokyo-night/tophat.sh diff --git a/install/desktop/theme.sh b/install/desktop/theme.sh new file mode 100644 index 000000000..d62de416b --- /dev/null +++ b/install/desktop/theme.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [[ -n "$1" ]]; then + INITIAL_THEME=$1 +else + INITIAL_THEME="tokyo-night" +fi + +# Setup theme links +if [ -d ~/.config/omakub/themes ]; then + rm -rf ~/.config/omakub/themes +fi + +# Create themes folder into user config +mkdir -p ~/.config/omakub/themes + +# Iterate all omakub themes creating/overriding symlinks for each theme into the user config themes folder +for f in ~/.local/share/omakub/themes/*; do ln -nfs "$f" ~/.config/omakub/themes/; done + +# Set initial theme +mkdir -p ~/.config/omakub/current +ln -snf ~/.config/omakub/themes/$INITIAL_THEME ~/.config/omakub/current/theme + +# Set specific app links for current theme +ln -snf ~/.config/omakub/current/theme/alacritty.toml ~/.config/alacritty/theme.toml + +ln -snf ~/.config/omakub/current/theme/zellij.kdl ~/.config/zellij/themes/$INITIAL_THEME.kdl +sed -i "s/theme \".*\"/theme \"$INITIAL_THEME\"/g" ~/.config/zellij/config.kdl + +ln -snf ~/.config/omakub/current/theme/neovim.lua ~/.config/nvim/lua/plugins/theme.lua + +if [ -f "~/.config/omakub/current/theme/btop.theme" ]; then + ln -snf ~/.config/omakub/current/theme/btop.theme ~/.config/btop/themes/$INITIAL_THEME.theme + sed -i "s/color_theme = \".*\"/color_theme = \"$INITIAL_THEME\"/g" ~/.config/btop/btop.conf +else + sed -i "s/color_theme = \".*\"/color_theme = \"Default\"/g" ~/.config/btop/btop.conf +fi + +source ~/.config/omakub/current/theme/gnome.sh +source ~/.config/omakub/current/theme/tophat.sh +source ~/.config/omakub/current/theme/vscode.sh \ No newline at end of file diff --git a/migrations/1754833639.sh b/migrations/1754833639.sh new file mode 100644 index 000000000..44060ffd1 --- /dev/null +++ b/migrations/1754833639.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +THEME_NAMES=("Tokyo Night" "Catppuccin" "Nord" "Everforest" "Gruvbox" "Kanagawa" "Ristretto" "Rose Pine" "Matte Black") +THEME=$(gum choose "${THEME_NAMES[@]}" "Default" --header "Choose your theme" --height 12 | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g') + +# The the new theme management feature directories are created +if [ -n "$THEME" ] && [ "$THEME" != "default" ]; then + source $OMAKUB_PATH/install/desktop/theme.sh "$THEME" +else + source $OMAKUB_PATH/install/desktop/theme.sh +fi diff --git a/themes/set-gnome-theme.sh b/themes/set-gnome-theme.sh index 0df937162..f6d3606b2 100644 --- a/themes/set-gnome-theme.sh +++ b/themes/set-gnome-theme.sh @@ -6,13 +6,14 @@ gsettings set org.gnome.desktop.interface gtk-theme "Yaru-$OMAKUB_THEME_COLOR-da gsettings set org.gnome.desktop.interface icon-theme "Yaru-$OMAKUB_THEME_COLOR" gsettings set org.gnome.desktop.interface accent-color "$OMAKUB_THEME_COLOR" 2>/dev/null || true -BACKGROUND_ORG_PATH="$HOME/.local/share/omakub/themes/$OMAKUB_THEME_BACKGROUND" -BACKGROUND_DEST_DIR="$HOME/.local/share/backgrounds" +BACKGROUND_DEST_DIR="$HOME/.config/omakub/current/background" +BACKGROUND_FILENAME=$(basename "$OMAKUB_THEME_BACKGROUND") BACKGROUND_DEST_PATH="$BACKGROUND_DEST_DIR/$(echo $OMAKUB_THEME_BACKGROUND | tr '/' '-')" if [ ! -d "$BACKGROUND_DEST_DIR" ]; then mkdir -p "$BACKGROUND_DEST_DIR"; fi -[ ! -f $BACKGROUND_DEST_PATH ] && cp $BACKGROUND_ORG_PATH $BACKGROUND_DEST_PATH -gsettings set org.gnome.desktop.background picture-uri $BACKGROUND_DEST_PATH -gsettings set org.gnome.desktop.background picture-uri-dark $BACKGROUND_DEST_PATH +ln -snf $HOME/.config/omakub/current/theme/$BACKGROUND_FILENAME "$BACKGROUND_DEST_PATH" + +gsettings set org.gnome.desktop.background picture-uri "$BACKGROUND_DEST_PATH" +gsettings set org.gnome.desktop.background picture-uri-dark "$BACKGROUND_DEST_PATH" gsettings set org.gnome.desktop.background picture-options 'zoom'