Skip to content
Open
25 changes: 17 additions & 8 deletions bin/omakub-sub/theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions install/desktop/set-gnome-theme.sh

This file was deleted.

41 changes: 41 additions & 0 deletions install/desktop/theme.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about that, is there a smarter/simple way to achieve the same?


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
11 changes: 11 additions & 0 deletions migrations/1754833639.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 6 additions & 5 deletions themes/set-gnome-theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'