Extract theme-list and theme-set so they can be used more easily in any menu
This commit is contained in:
parent
552fbb47fe
commit
7e84755c75
21
bin/omarchy-theme-list
Executable file
21
bin/omarchy-theme-list
Executable file
@ -0,0 +1,21 @@
|
||||
#!/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 \) | sort | 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
|
||||
)
|
||||
|
||||
printf '%s\n' "${themes[@]}"
|
@ -1,31 +1,4 @@
|
||||
#!/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 \) | sort | 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
|
||||
)
|
||||
|
||||
# Show Walker menu
|
||||
selection=$(printf '%s\n' "${themes[@]}" | walker --dmenu --theme dmenu_250 -p "Choose Theme" 2>/dev/null)
|
||||
|
||||
# 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"
|
||||
"$HOME/.local/share/omarchy/bin/omarchy-theme-set" \
|
||||
"$(~/.local/share/omarchy/bin/omarchy-theme-list | walker --dmenu --theme dmenu_250 -p "Choose Theme" 2>/dev/null)"
|
||||
|
@ -3,7 +3,7 @@
|
||||
# omarchy-theme-set: Set a theme, specified by its name.
|
||||
# Usage: omarchy-theme-set <theme-name>
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
if [[ -z "$1" && "$1" != "CNCLD" ]]; then
|
||||
echo "Usage: omarchy-theme-set <theme-name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
@ -11,7 +11,7 @@ fi
|
||||
THEMES_DIR="$HOME/.config/omarchy/themes/"
|
||||
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
||||
|
||||
THEME_NAME="$1"
|
||||
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||
|
||||
# Check if the theme entered exists
|
||||
|
Loading…
x
Reference in New Issue
Block a user