Files
omarchy/bin/omarchy-theme-menu
2025-07-14 21:47:46 -07:00

39 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
THEMES_DIR="$HOME/.config/omarchy/themes/"
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
CURRENT_THEME_NAME=$(basename "$(realpath "$CURRENT_THEME_DIR")")
# Build themes list with pretty display names
mapfile -t themes < <(
find "$THEMES_DIR" -mindepth 1 -maxdepth 1 \( -type d -o -type l \) | while read -r path; do
filename=$(basename "$path")
display_name=$(echo "$filename" | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g')
if [[ "$filename" == "$CURRENT_THEME_NAME" ]]; then
echo "<i>$display_name</i>"
else
echo "$display_name"
fi
done | sort
)
# Show Wofi menu (with markup support)
selection=$(printf '%s\n' "${themes[@]}" | wofi \
--show dmenu \
--allow-markup \
--width 150 \
--height 300 \
-O alphabetical \
--style ~/.local/share/omarchy/default/wofi/select.css)
# Remove any Pango markup before converting back to filename
clean_selection=$(echo "$selection" | sed -E 's/<[^>]+>//g')
# Convert to lowercase and dash-separated: "Tokyo Night" -> "tokyo-night"
selected_theme=$(echo "$clean_selection" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
# Apply the selected theme
"$HOME/.local/share/omarchy/bin/omarchy-theme-set" "$selected_theme"