Files
omarchy/bin/omarchy-theme-set
2025-07-23 01:51:04 +03:00

55 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# omarchy-theme-set: Set a theme, specified by its name.
# Usage: omarchy-theme-set <theme-name>
if [[ -z "$1" ]]; then
echo "Usage: omarchy-theme-set <theme-name>" >&2
exit 1
fi
THEMES_DIR="$HOME/.config/omarchy/themes/"
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
THEME_NAME="$1"
THEME_PATH="$THEMES_DIR/$THEME_NAME"
if [[ -d "$HOME/.config/omarchy/themes/$THEME_NAME/backgrounds" ]]; then
BACKGROUND_PATH="$HOME/.config/omarchy/themes/$THEME_NAME/backgrounds"
else
BACKGROUND_PATH="$HOME/.config/omarchy/backgrounds/$THEME_NAME"
fi
# Check if the theme entered exists
if [[ ! -d "$THEME_PATH" ]]; then
echo "Theme '$THEME_NAME' does not exist in $THEMES_DIR" >&2
exit 2
fi
# Update theme symlinks
ln -nsf "$THEME_PATH" "$CURRENT_THEME_DIR"
# Change gnome modes
if [[ -f ~/.config/omarchy/current/theme/light.mode ]]; then
gsettings set org.gnome.desktop.interface color-scheme "prefer-light"
gsettings set org.gnome.desktop.interface gtk-theme "Adwaita"
else
gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
gsettings set org.gnome.desktop.interface gtk-theme "Adwaita-dark"
fi
# Trigger alacritty config reload
touch "$HOME/.config/alacritty/alacritty.toml"
# Trigger btop config reload
pkill -SIGUSR2 btop
# Restart components to apply new theme
pkill -SIGUSR2 waybar
pkill -SIGUSR2 swayosd-server
makoctl reload
hyprctl reload
# Set new background
"$HOME/.local/share/omarchy/bin/omarchy-theme-bg-next"