mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Split user themes and default themes
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
find ~/.config/omarchy/themes/ -mindepth 1 -maxdepth 1 \( -type d -o -type l \) | sort | while read -r path; do
|
{
|
||||||
echo "$(basename "$path" | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g')"
|
find ~/.config/omarchy/themes/ -mindepth 1 -maxdepth 1 \( -type d -o -type l \) -printf '%f\n'
|
||||||
|
find "$OMARCHY_PATH/themes/" -mindepth 1 -maxdepth 1 -type d -printf '%f\n'
|
||||||
|
} | sort -u | while read -r name; do
|
||||||
|
echo "$name" | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g'
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,9 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
THEMES_DIR="$HOME/.config/omarchy/themes/"
|
|
||||||
CURRENT_THEME_LINK="$HOME/.config/omarchy/current/theme"
|
CURRENT_THEME_LINK="$HOME/.config/omarchy/current/theme"
|
||||||
|
|
||||||
THEMES=($(find "$THEMES_DIR" -mindepth 1 -maxdepth 1 | sort))
|
declare -A theme_paths
|
||||||
|
|
||||||
|
while IFS= read -r path; do
|
||||||
|
name=$(basename "$path")
|
||||||
|
theme_paths[$name]="$path"
|
||||||
|
done < <(find ~/.config/omarchy/themes/ -mindepth 1 -maxdepth 1 \( -type d -o -type l \) | sort)
|
||||||
|
|
||||||
|
while IFS= read -r path; do
|
||||||
|
name=$(basename "$path")
|
||||||
|
if [[ -z "${theme_paths[$name]}" ]]; then
|
||||||
|
theme_paths[$name]="$path"
|
||||||
|
fi
|
||||||
|
done < <(find "$OMARCHY_PATH/themes/" -mindepth 1 -maxdepth 1 -type d | sort)
|
||||||
|
|
||||||
|
IFS=$'\n' THEMES=($(for name in "${!theme_paths[@]}"; do echo "$name"; done | sort))
|
||||||
|
IFS=$'\n' THEMES_FULL=($(for name in "${!theme_paths[@]}"; do echo "${theme_paths[$name]}"; done | sort))
|
||||||
|
|
||||||
TOTAL=${#THEMES[@]}
|
TOTAL=${#THEMES[@]}
|
||||||
|
|
||||||
# Get current theme from symlink
|
# Get current theme from symlink
|
||||||
@@ -11,15 +26,15 @@ if [[ -L "$CURRENT_THEME_LINK" ]]; then
|
|||||||
CURRENT_THEME=$(realpath "$CURRENT_THEME_LINK")
|
CURRENT_THEME=$(realpath "$CURRENT_THEME_LINK")
|
||||||
else
|
else
|
||||||
# Default to first theme if no symlink exists
|
# Default to first theme if no symlink exists
|
||||||
CURRENT_THEME=$(realpath "${THEMES[0]}")
|
CURRENT_THEME=$(realpath "${THEMES_FULL[0]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find current theme index
|
# Find current theme index
|
||||||
INDEX=0
|
INDEX=0
|
||||||
for i in "${!THEMES[@]}"; do
|
for i in "${!THEMES_FULL[@]}"; do
|
||||||
THEMES[$i]=$(realpath "${THEMES[$i]}")
|
THEME_REAL=$(realpath "${THEMES_FULL[$i]}")
|
||||||
|
|
||||||
if [[ "${THEMES[$i]}" == "$CURRENT_THEME" ]]; then
|
if [[ "$THEME_REAL" == "$CURRENT_THEME" ]]; then
|
||||||
INDEX=$i
|
INDEX=$i
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -27,8 +42,7 @@ done
|
|||||||
|
|
||||||
# Get next theme (wrap around)
|
# Get next theme (wrap around)
|
||||||
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
||||||
NEW_THEME=${THEMES[$NEXT_INDEX]}
|
NEW_THEME_NAME=${THEMES[$NEXT_INDEX]}
|
||||||
NEW_THEME_NAME=$(basename "$NEW_THEME")
|
|
||||||
|
|
||||||
omarchy-theme-set $NEW_THEME_NAME
|
omarchy-theme-set $NEW_THEME_NAME
|
||||||
notify-send "Theme changed to $NEW_THEME_NAME" -t 2000
|
notify-send "Theme changed to $NEW_THEME_NAME" -t 2000
|
||||||
|
|||||||
@@ -7,11 +7,16 @@ fi
|
|||||||
|
|
||||||
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
|
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
|
||||||
NEXT_THEME_PATH="$HOME/.config/omarchy/current/next-theme"
|
NEXT_THEME_PATH="$HOME/.config/omarchy/current/next-theme"
|
||||||
|
USER_THEMES_PATH="$HOME/.config/omarchy/themes"
|
||||||
|
OMARCHY_THEMES_PATH="$OMARCHY_PATH/themes"
|
||||||
|
|
||||||
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||||
THEME_PATH="$HOME/.config/omarchy/themes/$THEME_NAME"
|
|
||||||
|
|
||||||
if [[ ! -d "$THEME_PATH" ]]; then
|
if [[ -d "$USER_THEMES_PATH/$THEME_NAME" ]]; then
|
||||||
|
THEME_PATH="$USER_THEMES_PATH/$THEME_NAME"
|
||||||
|
elif [[ -d "$USER_THEMES_PATH/$THEME_NAME" ]]; then
|
||||||
|
THEME_PATH="$OMARCHY_PATH/$THEME_NAME"
|
||||||
|
else
|
||||||
echo "Theme '$THEME_NAME' does not exist"
|
echo "Theme '$THEME_NAME' does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user