refactor(themes): move theme assets under omarchy-themes
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Check whether any required commands are missing
|
||||
|
||||
for cmd in "$@"; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
exit 1
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Check whether all required commands are available
|
||||
|
||||
for cmd in "$@"; do
|
||||
command -v "$cmd" &>/dev/null || exit 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Run a named hook from ~/.config/omarchy/hooks/<name> and ~/.config/omarchy/hooks/<name>.d/.
|
||||
# omarchy:args=[name] [args...]
|
||||
|
||||
set -e
|
||||
|
||||
if (( $# < 1 )); then
|
||||
echo "Usage: omarchy-hook [name] [args...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOOK=$1
|
||||
HOOK_PATH="$HOME/.config/omarchy/hooks/$1"
|
||||
HOOK_DIR="$HOOK_PATH.d"
|
||||
shift
|
||||
|
||||
if [[ -f $HOOK_PATH ]]; then
|
||||
bash "$HOOK_PATH" "$@" || echo "Hook failed: $HOOK_PATH"
|
||||
fi
|
||||
|
||||
if [[ -d $HOOK_DIR ]]; then
|
||||
for hook in "$HOOK_DIR"/*; do
|
||||
[[ -f $hook ]] || continue
|
||||
[[ $hook == *.sample ]] && continue
|
||||
bash "$hook" "$@" || echo "Hook failed: $hook"
|
||||
done
|
||||
fi
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Reload btop configuration (used by the Omarchy theme switching).
|
||||
|
||||
pkill -SIGUSR2 btop
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Reload hyprland configuration (used by the Omarchy theme switching).
|
||||
|
||||
hyprctl reload >/dev/null
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Restart the hypridle service (used for idle detection and auto-lock).
|
||||
|
||||
omarchy-restart-app hypridle
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Reload mako configuration (used by the Omarchy theme switching).
|
||||
|
||||
makoctl reload
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Restart tmux if running with the latest configuration
|
||||
|
||||
if pgrep --quiet tmux; then
|
||||
tmux source-file ~/.config/tmux/tmux.conf
|
||||
fi
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Cycle to the next background for the current theme
|
||||
# omarchy:examples=omarchy theme bg next
|
||||
|
||||
THEME_NAME=$(cat "$HOME/.local/state/omarchy/current/theme.name" 2>/dev/null)
|
||||
THEME_BACKGROUNDS_PATH="$HOME/.local/state/omarchy/current/theme/backgrounds/"
|
||||
USER_BACKGROUNDS_PATH="$HOME/.config/omarchy/backgrounds/$THEME_NAME/"
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.local/state/omarchy/current/background"
|
||||
|
||||
mapfile -d '' -t BACKGROUNDS < <(find -L "$USER_BACKGROUNDS_PATH" "$THEME_BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z)
|
||||
TOTAL=${#BACKGROUNDS[@]}
|
||||
|
||||
if (( TOTAL == 0 )); then
|
||||
notify-send "No background was found for theme" -t 2000
|
||||
setsid uwsm app -- awww clear >/dev/null 2>&1 &
|
||||
else
|
||||
# Get current background from symlink
|
||||
if [[ -L $CURRENT_BACKGROUND_LINK ]]; then
|
||||
CURRENT_BACKGROUND=$(readlink "$CURRENT_BACKGROUND_LINK")
|
||||
else
|
||||
# Default to first background if no symlink exists
|
||||
CURRENT_BACKGROUND=""
|
||||
fi
|
||||
|
||||
# Find current background index
|
||||
INDEX=-1
|
||||
for i in "${!BACKGROUNDS[@]}"; do
|
||||
if [[ ${BACKGROUNDS[$i]} == $CURRENT_BACKGROUND ]]; then
|
||||
INDEX=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Get next background (wrap around)
|
||||
if (( INDEX == -1 )); then
|
||||
# Use the first background when no match was found
|
||||
NEW_BACKGROUND="${BACKGROUNDS[0]}"
|
||||
else
|
||||
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
||||
NEW_BACKGROUND="${BACKGROUNDS[$NEXT_INDEX]}"
|
||||
fi
|
||||
|
||||
# Set new background symlink
|
||||
ln -nsf "$NEW_BACKGROUND" "$CURRENT_BACKGROUND_LINK"
|
||||
|
||||
setsid uwsm app -- awww img "$CURRENT_BACKGROUND_LINK" >/dev/null 2>&1 &
|
||||
fi
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Set the current background image
|
||||
# omarchy:args=<path-to-image>
|
||||
# omarchy:examples=omarchy theme bg set ~/Pictures/wallpaper.png
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Usage: omarchy-theme-bg-set <path-to-image>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BACKGROUND="$(realpath "$1")"
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.local/state/omarchy/current/background"
|
||||
|
||||
if [[ ! -f "$BACKGROUND" ]]; then
|
||||
echo "File does not exist: $BACKGROUND" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create symlink to the new background
|
||||
ln -nsf "$BACKGROUND" "$CURRENT_BACKGROUND_LINK"
|
||||
|
||||
# Kill existing swaybg and start new one
|
||||
pkill -x swaybg
|
||||
setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 &
|
||||
@@ -1,304 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Resolve semantic colors from an Omarchy theme colors.toml
|
||||
# omarchy:args=[--file <colors.toml>] (--all | --raw | <key> [fallback])
|
||||
# omarchy:hidden=true
|
||||
|
||||
# Shared colors.toml parser/resolver. The alias/fallback cascade mirrors what
|
||||
# omarchy-theme-set-templates bakes into the generated configs at theme-set
|
||||
# time, so every consumer (templates, OSC sequences, tmux, GNOME, previews)
|
||||
# resolves the exact same palette.
|
||||
#
|
||||
# --all print every resolved key<TAB>value pair (sorted by key)
|
||||
# --raw print only the key<TAB>value pairs defined in the file
|
||||
# <key> [fallback] print one resolved value; the fallback is tried as
|
||||
# another palette key first, then used verbatim
|
||||
#
|
||||
# Theme mode precedence: `mode` key, legacy `theme_type` key, a light.mode
|
||||
# file beside the colors.toml, background luminance auto-detect, dark.
|
||||
|
||||
COLORS_FILE="$HOME/.local/state/omarchy/current/theme/colors.toml"
|
||||
OUTPUT=""
|
||||
QUERY_KEY=""
|
||||
QUERY_FALLBACK=""
|
||||
|
||||
usage() {
|
||||
echo "Usage: omarchy-theme-color [--file <colors.toml>] (--all | --raw | <key> [fallback])"
|
||||
}
|
||||
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
--file)
|
||||
COLORS_FILE="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--all)
|
||||
OUTPUT="all"
|
||||
shift
|
||||
;;
|
||||
--raw)
|
||||
OUTPUT="raw"
|
||||
shift
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
if [[ -z $QUERY_KEY ]]; then
|
||||
QUERY_KEY="$1"
|
||||
elif [[ -z $QUERY_FALLBACK ]]; then
|
||||
QUERY_FALLBACK="$1"
|
||||
else
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z $OUTPUT && -z $QUERY_KEY ]] || [[ -n $OUTPUT && -n $QUERY_KEY ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COLORS_DIR=$(dirname "$COLORS_FILE")
|
||||
|
||||
declare -A THEME_COLORS
|
||||
|
||||
# Mix two hex colors. Amount may be a fraction (0.30) or percentage (30%).
|
||||
mix_color() {
|
||||
local start="${1#\#}"
|
||||
local end="${2#\#}"
|
||||
local amount="$3"
|
||||
|
||||
awk -v start="$start" -v end="$end" -v amount="$amount" '
|
||||
function hex_value(char) {
|
||||
return index("0123456789abcdef", tolower(char)) - 1
|
||||
}
|
||||
|
||||
function hex_pair_to_int(hex, idx) {
|
||||
return hex_value(substr(hex, idx, 1)) * 16 + hex_value(substr(hex, idx + 1, 1))
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
if (amount ~ /%$/) {
|
||||
sub(/%$/, "", amount)
|
||||
amount = amount / 100
|
||||
} else {
|
||||
amount += 0
|
||||
if (amount > 1) amount = amount / 100
|
||||
}
|
||||
|
||||
if (amount < 0) amount = 0
|
||||
if (amount > 1) amount = 1
|
||||
|
||||
start_r = hex_pair_to_int(start, 1)
|
||||
start_g = hex_pair_to_int(start, 3)
|
||||
start_b = hex_pair_to_int(start, 5)
|
||||
end_r = hex_pair_to_int(end, 1)
|
||||
end_g = hex_pair_to_int(end, 3)
|
||||
end_b = hex_pair_to_int(end, 5)
|
||||
|
||||
red = int(start_r * (1 - amount) + end_r * amount + 0.5)
|
||||
green = int(start_g * (1 - amount) + end_g * amount + 0.5)
|
||||
blue = int(start_b * (1 - amount) + end_b * amount + 0.5)
|
||||
|
||||
printf "#%02x%02x%02x\n", red, green, blue
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
alias_theme_color() {
|
||||
local key="$1"
|
||||
local fallback="$2"
|
||||
|
||||
[[ ${THEME_COLORS[$key]} ]] || THEME_COLORS[$key]="${THEME_COLORS[$fallback]}"
|
||||
}
|
||||
|
||||
resolve_theme_mode() {
|
||||
local bg_hex lum
|
||||
|
||||
[[ ${THEME_COLORS[mode]} ]] || THEME_COLORS[mode]="${THEME_COLORS[theme_type]}"
|
||||
[[ ${THEME_COLORS[mode]} ]] && return
|
||||
|
||||
if [[ -f $COLORS_DIR/light.mode ]]; then
|
||||
THEME_COLORS[mode]="light"
|
||||
elif [[ ${THEME_COLORS[background]} =~ ^#[0-9A-Fa-f]{6}$ ]]; then
|
||||
bg_hex="${THEME_COLORS[background]#\#}"
|
||||
lum=$(( $(printf "%d" "0x${bg_hex:0:2}") + $(printf "%d" "0x${bg_hex:2:2}") + $(printf "%d" "0x${bg_hex:4:2}") ))
|
||||
(( lum > 382 )) && THEME_COLORS[mode]="light" || THEME_COLORS[mode]="dark"
|
||||
else
|
||||
THEME_COLORS[mode]="dark"
|
||||
fi
|
||||
}
|
||||
|
||||
parse_colors_file() {
|
||||
local key value
|
||||
|
||||
[[ -f $COLORS_FILE ]] || return 0
|
||||
|
||||
while IFS='=' read -r key value; do
|
||||
key="${key//[\"\' ]/}" # strip quotes and spaces from key
|
||||
[[ $key && $key != \#* ]] || continue # skip empty lines and comments
|
||||
|
||||
if [[ $value == *[\"\']* ]]; then
|
||||
value="${value#*[\"\']}"
|
||||
value="${value%%[\"\']*}" # extract value between quotes (ignores inline comments)
|
||||
else
|
||||
value="${value#"${value%%[![:space:]]*}"}"
|
||||
value="${value%"${value##*[![:space:]]}"}" # trim unquoted values
|
||||
fi
|
||||
|
||||
# Values reach consumers as sed replacement text, so the charset excludes
|
||||
# the delimiter, backslash, and & while still covering everything a real
|
||||
# palette holds: hex, rgb()/rgba() lists, gradient angles like -45deg,
|
||||
# decimals, and bare words. Rejections are announced so a third-party theme
|
||||
# doesn't lose a key silently and leave a raw {{ placeholder }} behind.
|
||||
if [[ ! $key =~ ^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]+$ ]]; then
|
||||
printf 'omarchy-theme-color: skipping key with unsupported characters\n' >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ! $value =~ ^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#(),._+/%\ -]*$ ]]; then
|
||||
printf 'omarchy-theme-color: skipping %s: unsupported characters in value\n' "$key" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
THEME_COLORS[$key]="$value"
|
||||
[[ $OUTPUT == "raw" ]] && printf '%s\t%s\n' "$key" "$value"
|
||||
done <"$COLORS_FILE"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
resolve_theme_colors() {
|
||||
local key
|
||||
|
||||
# Accept the complete legacy short-name palette before applying ANSI
|
||||
# fallbacks or deriving shades. Canonical names take precedence when a theme
|
||||
# defines both forms.
|
||||
declare -A legacy_palette_alias=(
|
||||
[background]=bg
|
||||
[dark_background]=dark_bg
|
||||
[darker_background]=darker_bg
|
||||
[lighter_background]=lighter_bg
|
||||
[foreground]=fg
|
||||
[dark_foreground]=dark_fg
|
||||
[light_foreground]=light_fg
|
||||
[bright_foreground]=bright_fg
|
||||
)
|
||||
for key in "${!legacy_palette_alias[@]}"; do
|
||||
alias_theme_color "$key" "${legacy_palette_alias[$key]}"
|
||||
done
|
||||
|
||||
# Themes generated before the semantic palette may only define ANSI names.
|
||||
[[ ${THEME_COLORS[background]} ]] || THEME_COLORS[background]="${THEME_COLORS[color0]}"
|
||||
[[ ${THEME_COLORS[foreground]} ]] || THEME_COLORS[foreground]="${THEME_COLORS[color7]}"
|
||||
[[ ${THEME_COLORS[background]} ]] && THEME_COLORS[color0]="${THEME_COLORS[background]}"
|
||||
[[ ${THEME_COLORS[foreground]} ]] && THEME_COLORS[color7]="${THEME_COLORS[foreground]}"
|
||||
|
||||
# Legacy compatibility: map ANSI color0..color15 to semantic names.
|
||||
declare -A legacy_alias=(
|
||||
[red]=color1
|
||||
[green]=color2
|
||||
[yellow]=color3
|
||||
[blue]=color4
|
||||
[magenta]=color5
|
||||
[cyan]=color6
|
||||
[bright_red]=color9
|
||||
[bright_green]=color10
|
||||
[bright_yellow]=color11
|
||||
[bright_blue]=color12
|
||||
[bright_magenta]=color13
|
||||
[bright_cyan]=color14
|
||||
)
|
||||
for key in "${!legacy_alias[@]}"; do
|
||||
alias_theme_color "$key" "${legacy_alias[$key]}"
|
||||
done
|
||||
alias_theme_color magenta purple
|
||||
alias_theme_color bright_magenta bright_purple
|
||||
|
||||
[[ ${THEME_COLORS[light_foreground]} ]] || THEME_COLORS[light_foreground]="${THEME_COLORS[color7]:-${THEME_COLORS[foreground]}}"
|
||||
[[ ${THEME_COLORS[bright_foreground]} ]] || THEME_COLORS[bright_foreground]="${THEME_COLORS[color15]:-${THEME_COLORS[foreground]}}"
|
||||
THEME_COLORS[cursor]="${THEME_COLORS[bright_foreground]}"
|
||||
[[ ${THEME_COLORS[lighter_background]} ]] || THEME_COLORS[lighter_background]="${THEME_COLORS[color0]:-${THEME_COLORS[background]}}"
|
||||
[[ ${THEME_COLORS[dark_foreground]} ]] || THEME_COLORS[dark_foreground]="${THEME_COLORS[color8]:-${THEME_COLORS[foreground]}}"
|
||||
[[ ${THEME_COLORS[muted]} ]] || THEME_COLORS[muted]="${THEME_COLORS[color8]:-${THEME_COLORS[dark_foreground]}}"
|
||||
[[ ${THEME_COLORS[selection]} ]] || THEME_COLORS[selection]="${THEME_COLORS[selection_background]:-${THEME_COLORS[color8]:-${THEME_COLORS[color0]:-${THEME_COLORS[background]}}}}"
|
||||
[[ ${THEME_COLORS[selection_background]} ]] || THEME_COLORS[selection_background]="${THEME_COLORS[selection]}"
|
||||
[[ ${THEME_COLORS[selection_foreground]} ]] || THEME_COLORS[selection_foreground]="${THEME_COLORS[bright_foreground]}"
|
||||
[[ ${THEME_COLORS[orange]} ]] || THEME_COLORS[orange]="${THEME_COLORS[yellow]}"
|
||||
[[ ${THEME_COLORS[brown]} ]] || THEME_COLORS[brown]=$(mix_color "${THEME_COLORS[orange]}" "#000000" 50%)
|
||||
|
||||
# Auto-derive shades from base accents when not defined and not aliased from colorN
|
||||
[[ ${THEME_COLORS[dark_background]} ]] || THEME_COLORS[dark_background]=$(mix_color "${THEME_COLORS[background]}" "#000000" 25%)
|
||||
[[ ${THEME_COLORS[darker_background]} ]] || THEME_COLORS[darker_background]=$(mix_color "${THEME_COLORS[background]}" "#000000" 50%)
|
||||
[[ ${THEME_COLORS[bright_red]} ]] || THEME_COLORS[bright_red]=$(mix_color "${THEME_COLORS[red]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_yellow]} ]] || THEME_COLORS[bright_yellow]=$(mix_color "${THEME_COLORS[yellow]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_green]} ]] || THEME_COLORS[bright_green]=$(mix_color "${THEME_COLORS[green]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_cyan]} ]] || THEME_COLORS[bright_cyan]=$(mix_color "${THEME_COLORS[cyan]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_blue]} ]] || THEME_COLORS[bright_blue]=$(mix_color "${THEME_COLORS[blue]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_magenta]} ]] || THEME_COLORS[bright_magenta]=$(mix_color "${THEME_COLORS[magenta]}" "#ffffff" 20%)
|
||||
alias_theme_color purple magenta
|
||||
alias_theme_color bright_purple bright_magenta
|
||||
|
||||
# Keep semantic themes compatible with consumers that still reference the
|
||||
# legacy ANSI names directly.
|
||||
declare -A ansi_alias=(
|
||||
[color0]=background
|
||||
[color1]=red
|
||||
[color2]=green
|
||||
[color3]=yellow
|
||||
[color4]=blue
|
||||
[color5]=magenta
|
||||
[color6]=cyan
|
||||
[color7]=foreground
|
||||
[color8]=muted
|
||||
[color9]=bright_red
|
||||
[color10]=bright_green
|
||||
[color11]=bright_yellow
|
||||
[color12]=bright_blue
|
||||
[color13]=bright_magenta
|
||||
[color14]=bright_cyan
|
||||
[color15]=bright_foreground
|
||||
)
|
||||
for key in "${!ansi_alias[@]}"; do
|
||||
alias_theme_color "$key" "${ansi_alias[$key]}"
|
||||
done
|
||||
|
||||
# Keep canonical themes compatible with old user templates and consumers
|
||||
# that still query the short palette names directly.
|
||||
for key in "${!legacy_palette_alias[@]}"; do
|
||||
if [[ ${THEME_COLORS[$key]} ]]; then
|
||||
THEME_COLORS["${legacy_palette_alias[$key]}"]="${THEME_COLORS[$key]}"
|
||||
fi
|
||||
done
|
||||
|
||||
resolve_theme_mode
|
||||
THEME_COLORS[theme_type]="${THEME_COLORS[mode]}"
|
||||
}
|
||||
|
||||
parse_colors_file
|
||||
|
||||
if [[ $OUTPUT == "raw" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
resolve_theme_colors
|
||||
|
||||
if [[ $OUTPUT == "all" ]]; then
|
||||
while IFS= read -r key; do
|
||||
printf '%s\t%s\n' "$key" "${THEME_COLORS[$key]}"
|
||||
done < <(printf '%s\n' "${!THEME_COLORS[@]}" | LC_ALL=C sort)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
value="${THEME_COLORS[$QUERY_KEY]:-}"
|
||||
if [[ -z $value && -n $QUERY_FALLBACK ]]; then
|
||||
value="${THEME_COLORS[$QUERY_FALLBACK]:-$QUERY_FALLBACK}"
|
||||
fi
|
||||
|
||||
[[ -n $value ]] || exit 1
|
||||
printf '%s\n' "$value"
|
||||
@@ -1,211 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Generate a theme's colors.toml from its alacritty.toml palette
|
||||
# omarchy:args=<theme-dir>
|
||||
# omarchy:hidden=true
|
||||
|
||||
set -e
|
||||
|
||||
THEME_SOURCE="${1:-}"
|
||||
COLORS_OUTPUT="$THEME_SOURCE/colors.toml"
|
||||
ALACRITTY_FILE="$THEME_SOURCE/alacritty.toml"
|
||||
|
||||
if [[ -z $THEME_SOURCE ]]; then
|
||||
echo "Usage: omarchy-theme-colors-from-alacritty <theme-dir>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Skip if colors.toml already exists in source theme
|
||||
if [[ -f $COLORS_OUTPUT ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Skip if no alacritty.toml to extract from
|
||||
if [[ ! -f $ALACRITTY_FILE ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
normalize_hex() {
|
||||
local color="$1"
|
||||
[[ -z $color ]] && return
|
||||
color="${color#0x}"
|
||||
color="${color#\#}"
|
||||
if [[ $color =~ ^[0-9a-fA-F]{6}$ ]]; then
|
||||
printf "#%s\n" "${color,,}"
|
||||
fi
|
||||
}
|
||||
|
||||
extract_color_in_section() {
|
||||
local section="$1"
|
||||
local key="$2"
|
||||
local color_hex=""
|
||||
color_hex=$(awk -v section="$section" -v key="$key" '
|
||||
function trim(value) {
|
||||
gsub(/^[ \t]+|[ \t]+$/, "", value)
|
||||
return value
|
||||
}
|
||||
|
||||
function strip_comment(value, i, ch, out, in_single, in_double, prev) {
|
||||
out = ""
|
||||
in_single = 0
|
||||
in_double = 0
|
||||
prev = ""
|
||||
|
||||
for (i = 1; i <= length(value); i++) {
|
||||
ch = substr(value, i, 1)
|
||||
|
||||
if (ch == "\"" && !in_single && prev != "\\") {
|
||||
in_double = !in_double
|
||||
} else if (ch == "'\''" && !in_double) {
|
||||
in_single = !in_single
|
||||
}
|
||||
|
||||
if (ch == "#" && !in_single && !in_double) {
|
||||
break
|
||||
}
|
||||
|
||||
out = out ch
|
||||
prev = ch
|
||||
}
|
||||
|
||||
gsub(/[ \t]+$/, "", out)
|
||||
return out
|
||||
}
|
||||
|
||||
/^[ \t]*\[/ {
|
||||
in_section = ($0 ~ "^[ \\t]*\\[" section "\\][ \\t]*$")
|
||||
next
|
||||
}
|
||||
|
||||
in_section {
|
||||
line = $0
|
||||
line = strip_comment(line)
|
||||
|
||||
split_pos = index(line, "=")
|
||||
if (split_pos == 0) {
|
||||
next
|
||||
}
|
||||
|
||||
current_key = trim(substr(line, 1, split_pos - 1))
|
||||
current_value = trim(substr(line, split_pos + 1))
|
||||
|
||||
if (current_key == key) {
|
||||
gsub(/["'\''#]/, "", current_value)
|
||||
sub(/^0[xX]/, "", current_value)
|
||||
if (current_value ~ /^[0-9A-Fa-f]{6}$/) {
|
||||
print current_value
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
' "$ALACRITTY_FILE")
|
||||
|
||||
if [[ -n $color_hex && $color_hex =~ ^[0-9a-fA-F]{6}$ ]]; then
|
||||
normalize_hex "$color_hex"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
names=(black red green yellow blue magenta cyan white)
|
||||
|
||||
# Extract normal colors (color0-7)
|
||||
for i in {0..7}; do
|
||||
name="${names[$i]}"
|
||||
val=$(extract_color_in_section "colors.normal" "$name")
|
||||
if [[ -z $val ]]; then
|
||||
val=$(extract_color_in_section "colors" "normal.$name")
|
||||
fi
|
||||
|
||||
printf -v "color$i" "%s" "$val"
|
||||
done
|
||||
|
||||
# Validate we have all normal colors (required)
|
||||
for c in color0 color1 color2 color3 color4 color5 color6 color7; do
|
||||
if [[ -z ${!c} ]]; then
|
||||
echo "Warning: Cannot extract all normal colors from $ALACRITTY_FILE, skipping generation" >&2
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Extract bright colors (color8-15)
|
||||
for i in {0..7}; do
|
||||
normal="color$i"
|
||||
bright="color$((i + 8))"
|
||||
name="${names[$i]}"
|
||||
|
||||
val=$(extract_color_in_section "colors.bright" "$name")
|
||||
if [[ -z $val ]]; then
|
||||
val=$(extract_color_in_section "colors" "bright.$name")
|
||||
fi
|
||||
|
||||
printf -v "$bright" "%s" "${val:-${!normal}}"
|
||||
done
|
||||
|
||||
# Extract primary colors
|
||||
background=$(extract_color_in_section "colors.primary" "background")
|
||||
foreground=$(extract_color_in_section "colors.primary" "foreground")
|
||||
|
||||
if [[ -z $background ]]; then
|
||||
background=$(extract_color_in_section "colors" "primary.background")
|
||||
fi
|
||||
|
||||
if [[ -z $foreground ]]; then
|
||||
foreground=$(extract_color_in_section "colors" "primary.foreground")
|
||||
fi
|
||||
|
||||
# Extract cursor color (from [colors.cursor] section)
|
||||
cursor=$(extract_color_in_section "colors.cursor" "cursor")
|
||||
|
||||
if [[ -z $cursor ]]; then
|
||||
cursor=$(extract_color_in_section "colors" "cursor.cursor")
|
||||
fi
|
||||
|
||||
# Extract selection colors
|
||||
selection_background=$(extract_color_in_section "colors.selection" "background")
|
||||
|
||||
if [[ -z $selection_background ]]; then
|
||||
selection_background=$(extract_color_in_section "colors" "selection.background")
|
||||
fi
|
||||
|
||||
selection_foreground=$(extract_color_in_section "colors.selection" "text")
|
||||
|
||||
if [[ -z $selection_foreground ]]; then
|
||||
selection_foreground=$(extract_color_in_section "colors" "selection.text")
|
||||
fi
|
||||
|
||||
# Apply defaults
|
||||
background=${background:-$color0}
|
||||
foreground=${foreground:-$color7}
|
||||
cursor=${cursor:-$foreground}
|
||||
selection_background=${selection_background:-$foreground}
|
||||
selection_foreground=${selection_foreground:-$background}
|
||||
accent=$color4
|
||||
|
||||
mkdir -p "$THEME_SOURCE"
|
||||
|
||||
cat > "$COLORS_OUTPUT" <<EOF
|
||||
accent = "$accent"
|
||||
cursor = "$cursor"
|
||||
foreground = "$foreground"
|
||||
background = "$background"
|
||||
selection_foreground = "$selection_foreground"
|
||||
selection_background = "$selection_background"
|
||||
|
||||
color0 = "$color0"
|
||||
color1 = "$color1"
|
||||
color2 = "$color2"
|
||||
color3 = "$color3"
|
||||
color4 = "$color4"
|
||||
color5 = "$color5"
|
||||
color6 = "$color6"
|
||||
color7 = "$color7"
|
||||
color8 = "$color8"
|
||||
color9 = "$color9"
|
||||
color10 = "$color10"
|
||||
color11 = "$color11"
|
||||
color12 = "$color12"
|
||||
color13 = "$color13"
|
||||
color14 = "$color14"
|
||||
color15 = "$color15"
|
||||
EOF
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Show current theme
|
||||
# omarchy:examples=omarchy theme current
|
||||
|
||||
THEME_NAME_PATH="$HOME/.local/state/omarchy/current/theme.name"
|
||||
|
||||
if [[ -f $THEME_NAME_PATH ]]; then
|
||||
cat $THEME_NAME_PATH | sed -E 's/(^|-)([a-z])/\1\u\2/g; s/-/ /g'
|
||||
else
|
||||
echo "Unknown"
|
||||
fi
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Install a theme from a git repository
|
||||
# omarchy:args=[git-repo-url]
|
||||
# omarchy:examples=omarchy theme install https://github.com/example/omarchy-example-theme.git
|
||||
# omarchy:examples=omarchy theme install git@github.com:example/omarchy-example-theme.git
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo -e "\e[32mSee https://manuals.omamix.org/2/the-omarchy-manual/90/extra-themes\n\e[0m"
|
||||
REPO_URL=$(gum input --placeholder="Git repo URL (https or git@host:org/repo.git)" --header="")
|
||||
else
|
||||
REPO_URL="$1"
|
||||
fi
|
||||
|
||||
if [[ -z $REPO_URL ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
THEMES_DIR="$HOME/.config/omarchy/themes"
|
||||
|
||||
# Strip user@host: prefix from scp-style SSH URLs so basename sees just the path
|
||||
REPO_PATH="$REPO_URL"
|
||||
[[ $REPO_PATH != *"://"* && $REPO_PATH == *:*/* ]] && REPO_PATH="${REPO_PATH#*:}"
|
||||
THEME_NAME=$(basename "$REPO_PATH" .git | sed -E 's/^omarchy-//; s/-theme$//' | tr '[:upper:]' '[:lower:]')
|
||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||
|
||||
# Remove existing theme if present
|
||||
if [[ -d $THEME_PATH ]]; then
|
||||
rm -rf "$THEME_PATH"
|
||||
fi
|
||||
|
||||
# Clone the repo directly to ~/.config/omarchy/themes
|
||||
if ! git clone "$REPO_URL" "$THEME_PATH"; then
|
||||
echo "Error: Failed to clone theme repo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Apply the new theme with omarchy-theme-set
|
||||
omarchy-theme-set $THEME_NAME
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=List available themes
|
||||
# omarchy:examples=omarchy theme list | omarchy theme set "Tokyo Night"
|
||||
|
||||
{
|
||||
find ~/.config/omarchy/themes/ -mindepth 1 -maxdepth 1 \( -type d -o -type l \) -printf '%f\n'
|
||||
find "${DOTFILES_DIR}/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
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Refresh the current theme from its templates.
|
||||
|
||||
THEME_NAME_PATH="$HOME/.local/state/omarchy/current/theme.name"
|
||||
|
||||
if [[ -f $THEME_NAME_PATH ]]; then
|
||||
OMARCHY_THEME_SKIP_BACKGROUND=1 omarchy-theme-set "$(cat $THEME_NAME_PATH)"
|
||||
fi
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Remove a user-installed theme
|
||||
# omarchy:args=[theme-name]
|
||||
# omarchy:examples=omarchy theme remove "Tokyo Night"
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
mapfile -t extra_themes < <(find ~/.config/omarchy/themes -mindepth 1 -maxdepth 1 -type d ! -xtype l -printf '%f\n')
|
||||
|
||||
if (( ${#extra_themes[@]} > 0 )); then
|
||||
THEME_NAME=$(printf '%s\n' "${extra_themes[@]}" | sort | gum choose --header="Remove extra theme")
|
||||
else
|
||||
echo "No extra themes installed."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
THEME_NAME="$1"
|
||||
fi
|
||||
|
||||
THEMES_DIR="$HOME/.config/omarchy/themes"
|
||||
CURRENT_DIR="$HOME/.local/state/omarchy/current"
|
||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||
|
||||
# Ensure a theme was set
|
||||
if [[ -z $THEME_NAME ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if theme exists before attempting removal
|
||||
if [[ ! -d $THEME_PATH ]]; then
|
||||
echo "Error: Theme '$THEME_NAME' not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Now remove the theme directory for THEME_NAME
|
||||
rm -rf "$THEME_PATH"
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply an Omarchy theme
|
||||
# omarchy:args=<theme-name>
|
||||
# omarchy:examples=omarchy theme list | omarchy theme set "Tokyo Night"
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Usage: omarchy-theme-set <theme-name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CURRENT_THEME_PATH="$HOME/.local/state/omarchy/current/theme"
|
||||
NEXT_THEME_PATH="$HOME/.local/state/omarchy/current/next-theme"
|
||||
USER_THEMES_PATH="$HOME/.config/omarchy/themes"
|
||||
OMARCHY_THEMES_PATH="${DOTFILES_DIR}/themes"
|
||||
|
||||
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||
|
||||
if [[ ! -d $OMARCHY_THEMES_PATH/$THEME_NAME ]] && [[ ! -d $USER_THEMES_PATH/$THEME_NAME ]]; then
|
||||
echo "Theme '$THEME_NAME' does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Setup clean next theme directory (for atomic theme config swapping)
|
||||
rm -rf "$NEXT_THEME_PATH"
|
||||
mkdir -p "$NEXT_THEME_PATH"
|
||||
|
||||
# Copy official theme first, then overlay user customizations on top
|
||||
cp -r "$OMARCHY_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
|
||||
cp -r "$USER_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
|
||||
|
||||
# Generate colors.toml from alacritty.toml if theme is missing colors.toml
|
||||
if [[ ! -f $NEXT_THEME_PATH/colors.toml && -f $NEXT_THEME_PATH/alacritty.toml ]]; then
|
||||
omarchy-theme-colors-from-alacritty "$NEXT_THEME_PATH"
|
||||
fi
|
||||
|
||||
# Generate dynamic configs
|
||||
omarchy-theme-set-templates
|
||||
|
||||
# Swap next theme in as current
|
||||
rm -rf "$CURRENT_THEME_PATH"
|
||||
mv "$NEXT_THEME_PATH" "$CURRENT_THEME_PATH"
|
||||
|
||||
# Store theme name for reference
|
||||
echo "$THEME_NAME" >"$HOME/.local/state/omarchy/current/theme.name"
|
||||
|
||||
# Change background with theme
|
||||
if [[ $OMARCHY_THEME_SKIP_BACKGROUND != "1" ]]; then
|
||||
omarchy-theme-bg-next
|
||||
fi
|
||||
|
||||
# # Restart components to apply new theme
|
||||
# if pgrep -x waybar >/dev/null; then
|
||||
# omarchy-restart-waybar
|
||||
# fi
|
||||
# omarchy-restart-swayosd
|
||||
# omarchy-restart-terminal
|
||||
omarchy-restart-hyprctl
|
||||
omarchy-restart-btop
|
||||
# omarchy-restart-opencode
|
||||
omarchy-restart-mako
|
||||
omarchy-restart-tmux
|
||||
# omarchy-restart-helix
|
||||
|
||||
# Change app-specific themes
|
||||
omarchy-theme-set-foot
|
||||
omarchy-theme-set-gnome
|
||||
omarchy-theme-set-browser
|
||||
#omarchy-theme-set-vscode
|
||||
omarchy-theme-set-obsidian
|
||||
#omarchy-theme-set-keyboard
|
||||
|
||||
# Call hook on theme set
|
||||
omarchy-hook theme-set "$THEME_NAME" >/dev/null
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme color to Chromium, Chrome, Edge, and Brave
|
||||
# omarchy:hidden=true
|
||||
|
||||
CHROMIUM_THEME=~/.local/state/omarchy/current/theme/chromium.theme
|
||||
|
||||
if [[ -f $CHROMIUM_THEME ]]; then
|
||||
THEME_RGB_COLOR=$(<$CHROMIUM_THEME)
|
||||
THEME_HEX_COLOR=$(printf '#%02x%02x%02x' ${THEME_RGB_COLOR//,/ })
|
||||
else
|
||||
# Use a default, neutral grey if theme doesn't have a color
|
||||
THEME_HEX_COLOR="#1c2027"
|
||||
fi
|
||||
|
||||
set_browser_policy() {
|
||||
local policy_dir="$1"
|
||||
|
||||
[[ -d $policy_dir ]] || return
|
||||
echo "{\"BrowserThemeColor\": \"$THEME_HEX_COLOR\", \"BrowserColorScheme\": \"device\"}" | tee "$policy_dir/color.json" >/dev/null
|
||||
}
|
||||
|
||||
refresh_running_browser() {
|
||||
local process="$1"
|
||||
local command="$2"
|
||||
local pgrep_args="${3:--x}"
|
||||
|
||||
if omarchy-cmd-present "$command" && pgrep $pgrep_args "$process" >/dev/null; then
|
||||
"$command" --refresh-platform-policy --no-startup-window &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
set_browser_policy /etc/chromium/policies/managed
|
||||
refresh_running_browser chromium chromium
|
||||
|
||||
set_browser_policy /etc/opt/chrome/policies/managed
|
||||
refresh_running_browser chrome google-chrome-stable || refresh_running_browser chrome google-chrome
|
||||
|
||||
set_browser_policy /etc/opt/edge/policies/managed
|
||||
refresh_running_browser msedge microsoft-edge-stable
|
||||
|
||||
set_browser_policy /etc/brave/policies/managed
|
||||
refresh_running_browser brave brave
|
||||
refresh_running_browser brave-origin-beta brave-origin-beta -f
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply current Omarchy theme colors to running Foot terminals
|
||||
# omarchy:hidden=true
|
||||
|
||||
foot_theme=~/.local/state/omarchy/current/theme/foot.ini
|
||||
|
||||
if [[ ! -f $foot_theme ]] || ! pgrep -x foot >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
foot_osc=$(awk -F= '
|
||||
function color(value) { return "#" value }
|
||||
/^foreground=/ { printf "\033]10;%s\007", color($2) }
|
||||
/^background=/ { printf "\033]11;%s\007", color($2) }
|
||||
/^cursor=/ { split($2, parts, " "); printf "\033]12;%s\007", color(parts[2]) }
|
||||
/^selection-background=/ { printf "\033]17;%s\007", color($2) }
|
||||
/^selection-foreground=/ { printf "\033]19;%s\007", color($2) }
|
||||
/^regular[0-7]=/ { split($1, parts, "regular"); printf "\033]4;%d;%s\007", parts[2], color($2) }
|
||||
/^bright[0-7]=/ { split($1, parts, "bright"); printf "\033]4;%d;%s\007", parts[2] + 8, color($2) }
|
||||
' "$foot_theme")
|
||||
|
||||
for foot_pid in $(pgrep -x foot); do
|
||||
for child_pid in $(pgrep -P "$foot_pid"); do
|
||||
tty=$(readlink "/proc/$child_pid/fd/1" 2>/dev/null)
|
||||
[[ $tty == /dev/pts/* ]] && printf '%b' "$foot_osc" >"$tty"
|
||||
done
|
||||
done
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme to GNOME color mode and icon settings
|
||||
# omarchy:hidden=true
|
||||
|
||||
if [[ -f ~/.local/state/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
|
||||
|
||||
# Change gnome icon theme color
|
||||
GNOME_ICONS_THEME=~/.local/state/omarchy/current/theme/icons.theme
|
||||
if [[ -f $GNOME_ICONS_THEME ]]; then
|
||||
gsettings set org.gnome.desktop.interface icon-theme "$(<$GNOME_ICONS_THEME)"
|
||||
else
|
||||
gsettings set org.gnome.desktop.interface icon-theme "Yaru-blue"
|
||||
fi
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme keyboard color to supported keyboards
|
||||
# omarchy:hidden=true
|
||||
|
||||
omarchy-theme-set-keyboard-asus-rog
|
||||
omarchy-theme-set-keyboard-f16
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme keyboard color to ASUS ROG keyboards
|
||||
# omarchy:hidden=true
|
||||
|
||||
ASUSCTL_THEME=~/.local/state/omarchy/current/theme/keyboard.rgb
|
||||
|
||||
if omarchy-cmd-present asusctl; then
|
||||
asusctl aura effect static -c $(sed 's/^#//' $ASUSCTL_THEME)
|
||||
fi
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme keyboard color to Framework Laptop 16 keyboards
|
||||
# omarchy:hidden=true
|
||||
|
||||
FRAMEWORK16_THEME=~/.local/state/omarchy/current/theme/keyboard.rgb
|
||||
|
||||
if omarchy-cmd-present qmk_hid && [[ -f $FRAMEWORK16_THEME ]]; then
|
||||
hex=$(cat "$FRAMEWORK16_THEME")
|
||||
hex="${hex#\#}"
|
||||
|
||||
# Convert hex to QMK HSV (0-255 scale) using Python's colorsys
|
||||
read -r h s <<< $(python3 -c "
|
||||
import colorsys
|
||||
r, g, b = int('$hex'[:2],16)/255, int('$hex'[2:4],16)/255, int('$hex'[4:6],16)/255
|
||||
h, s, v = colorsys.rgb_to_hsv(r, g, b)
|
||||
print(int(h * 255), int(s * 255))
|
||||
")
|
||||
|
||||
qmk_hid via --rgb-effect 1 2>/dev/null
|
||||
qmk_hid via --rgb-hue "$h" 2>/dev/null
|
||||
qmk_hid via --rgb-saturation "$s" 2>/dev/null
|
||||
qmk_hid via --rgb-brightness 100 2>/dev/null
|
||||
qmk_hid via --save 2>/dev/null
|
||||
fi
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Sync Omarchy theme to all Obsidian vaults
|
||||
# omarchy:hidden=true
|
||||
|
||||
CURRENT_THEME_DIR="$HOME/.local/state/omarchy/current/theme"
|
||||
|
||||
[[ -f $CURRENT_THEME_DIR/obsidian.css ]] || exit 0
|
||||
|
||||
jq -r '.vaults | values[].path' ~/.config/obsidian/obsidian.json 2>/dev/null | while read -r vault_path; do
|
||||
[[ -d $vault_path/.obsidian ]] || continue
|
||||
|
||||
theme_dir="$vault_path/.obsidian/themes/Omarchy"
|
||||
mkdir -p "$theme_dir"
|
||||
|
||||
[[ -f $theme_dir/manifest.json ]] || cat >"$theme_dir/manifest.json" <<'EOF'
|
||||
{
|
||||
"name": "Omarchy",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.16.0",
|
||||
"description": "Automatically syncs with your current Omarchy system theme colors and fonts",
|
||||
"author": "Omarchy",
|
||||
"authorUrl": "https://omarchy.org"
|
||||
}
|
||||
EOF
|
||||
|
||||
cp "$CURRENT_THEME_DIR/obsidian.css" "$theme_dir/theme.css"
|
||||
done
|
||||
@@ -1,404 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Generate themed config files from Omarchy templates
|
||||
# omarchy:hidden=true
|
||||
|
||||
TEMPLATES_DIR="$DOTFILES_DIR/default/themed"
|
||||
USER_TEMPLATES_DIR="$HOME/.config/omarchy/themed"
|
||||
NEXT_THEME_DIR="$HOME/.local/state/omarchy/current/next-theme"
|
||||
COLORS_FILE="$NEXT_THEME_DIR/colors.toml"
|
||||
|
||||
declare -A THEME_COLORS
|
||||
|
||||
# Convert hex color to decimal RGB (e.g., "#1e1e2e" -> "30,30,46")
|
||||
hex_to_rgb() {
|
||||
local hex="${1#\#}"
|
||||
printf "%d,%d,%d" "0x${hex:0:2}" "0x${hex:2:2}" "0x${hex:4:2}"
|
||||
}
|
||||
|
||||
# Mix two hex colors. Amount may be a fraction (0.30) or percentage (30%).
|
||||
mix_color() {
|
||||
local start="${1#\#}"
|
||||
local end="${2#\#}"
|
||||
local amount="$3"
|
||||
|
||||
awk -v start="$start" -v end="$end" -v amount="$amount" '
|
||||
function hex_value(char) {
|
||||
return index("0123456789abcdef", tolower(char)) - 1
|
||||
}
|
||||
|
||||
function hex_pair_to_int(hex, idx) {
|
||||
return hex_value(substr(hex, idx, 1)) * 16 + hex_value(substr(hex, idx + 1, 1))
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
if (amount ~ /%$/) {
|
||||
sub(/%$/, "", amount)
|
||||
amount = amount / 100
|
||||
} else {
|
||||
amount += 0
|
||||
if (amount > 1) amount = amount / 100
|
||||
}
|
||||
|
||||
if (amount < 0) amount = 0
|
||||
if (amount > 1) amount = 1
|
||||
|
||||
start_r = hex_pair_to_int(start, 1)
|
||||
start_g = hex_pair_to_int(start, 3)
|
||||
start_b = hex_pair_to_int(start, 5)
|
||||
end_r = hex_pair_to_int(end, 1)
|
||||
end_g = hex_pair_to_int(end, 3)
|
||||
end_b = hex_pair_to_int(end, 5)
|
||||
|
||||
red = int(start_r * (1 - amount) + end_r * amount + 0.5)
|
||||
green = int(start_g * (1 - amount) + end_g * amount + 0.5)
|
||||
blue = int(start_b * (1 - amount) + end_b * amount + 0.5)
|
||||
|
||||
printf "#%02x%02x%02x\n", red, green, blue
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
trim() {
|
||||
local value="$1"
|
||||
|
||||
value="${value#"${value%%[![:space:]]*}"}"
|
||||
value="${value%"${value##*[![:space:]]}"}"
|
||||
printf "%s" "$value"
|
||||
}
|
||||
|
||||
resolve_theme_ref() {
|
||||
local ref="$1"
|
||||
local fallback="${2:-}"
|
||||
|
||||
if [[ -n ${THEME_COLORS[$ref]+_} ]]; then
|
||||
printf "%s" "${THEME_COLORS[$ref]}"
|
||||
elif [[ -n $fallback && -n ${THEME_COLORS[$fallback]+_} ]]; then
|
||||
printf "%s" "${THEME_COLORS[$fallback]}"
|
||||
elif [[ -n $fallback ]]; then
|
||||
printf "%s" "$fallback"
|
||||
else
|
||||
printf "%s" "$ref"
|
||||
fi
|
||||
}
|
||||
|
||||
resolve_gradient_color() {
|
||||
local color
|
||||
|
||||
color=$(trim "$1")
|
||||
if [[ -n ${THEME_COLORS[$color]+_} ]]; then
|
||||
color="${THEME_COLORS[$color]}"
|
||||
fi
|
||||
|
||||
printf "%s" "$color"
|
||||
}
|
||||
|
||||
parse_gradient() {
|
||||
local spec="$1"
|
||||
local part color
|
||||
local -a parts
|
||||
|
||||
GRADIENT_COLORS=()
|
||||
GRADIENT_ANGLE=""
|
||||
|
||||
read -ra parts <<<"$spec"
|
||||
for part in "${parts[@]}"; do
|
||||
[[ -n $part ]] || continue
|
||||
|
||||
if [[ $part =~ ^-?[0-9]+([.][0-9]+)?deg$ ]]; then
|
||||
GRADIENT_ANGLE="${part%deg}"
|
||||
else
|
||||
color=$(resolve_gradient_color "$part")
|
||||
GRADIENT_COLORS+=("$color")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
color_to_shell_hex() {
|
||||
local color r g b
|
||||
|
||||
color=$(resolve_gradient_color "$1")
|
||||
|
||||
if [[ $color =~ ^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$ ]]; then
|
||||
printf "#%s" "${color:1:6}"
|
||||
elif [[ $color =~ ^[Rr][Gg][Bb][Aa]?\(([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?\)$ ]]; then
|
||||
printf "#%s" "${BASH_REMATCH[1]}"
|
||||
elif [[ $color =~ ^[Rr][Gg][Bb][Aa]?\(([0-9]+),([0-9]+),([0-9]+)(,[0-9.]+)?\)$ ]]; then
|
||||
r=${BASH_REMATCH[1]}
|
||||
g=${BASH_REMATCH[2]}
|
||||
b=${BASH_REMATCH[3]}
|
||||
(( r > 255 )) && r=255
|
||||
(( g > 255 )) && g=255
|
||||
(( b > 255 )) && b=255
|
||||
printf "#%02x%02x%02x" "$r" "$g" "$b"
|
||||
elif [[ $color =~ ^0x[0-9A-Fa-f]{8}$ ]]; then
|
||||
printf "#%s" "${color:4:6}"
|
||||
else
|
||||
printf "%s" "$color"
|
||||
fi
|
||||
}
|
||||
|
||||
hypr_gradient_value() {
|
||||
local spec color index
|
||||
|
||||
spec=$(resolve_theme_ref "$1" "${2:-}")
|
||||
parse_gradient "$spec"
|
||||
|
||||
if (( ${#GRADIENT_COLORS[@]} == 0 )); then
|
||||
printf '"%s"' "$spec"
|
||||
elif (( ${#GRADIENT_COLORS[@]} == 1 )); then
|
||||
printf '"%s"' "${GRADIENT_COLORS[0]}"
|
||||
else
|
||||
printf '{ colors = {'
|
||||
for index in "${!GRADIENT_COLORS[@]}"; do
|
||||
(( index > 0 )) && printf ','
|
||||
printf ' "%s"' "${GRADIENT_COLORS[$index]}"
|
||||
done
|
||||
printf ' }'
|
||||
[[ -n $GRADIENT_ANGLE ]] && printf ', angle = %s' "$GRADIENT_ANGLE"
|
||||
printf ' }'
|
||||
fi
|
||||
}
|
||||
|
||||
gradient_start_value() {
|
||||
local spec
|
||||
|
||||
spec=$(resolve_theme_ref "$1" "${2:-}")
|
||||
parse_gradient "$spec"
|
||||
|
||||
if (( ${#GRADIENT_COLORS[@]} == 0 )); then
|
||||
color_to_shell_hex "$spec"
|
||||
else
|
||||
color_to_shell_hex "${GRADIENT_COLORS[0]}"
|
||||
fi
|
||||
}
|
||||
|
||||
shell_gradient_value() {
|
||||
local spec index
|
||||
|
||||
spec=$(resolve_theme_ref "$1" "${2:-}")
|
||||
parse_gradient "$spec"
|
||||
|
||||
if (( ${#GRADIENT_COLORS[@]} == 0 )); then
|
||||
printf "%s" "$spec"
|
||||
return
|
||||
fi
|
||||
|
||||
for index in "${!GRADIENT_COLORS[@]}"; do
|
||||
(( index > 0 )) && printf " "
|
||||
printf "%s" "${GRADIENT_COLORS[$index]}"
|
||||
done
|
||||
|
||||
[[ -n $GRADIENT_ANGLE ]] && printf " %sdeg" "$GRADIENT_ANGLE"
|
||||
}
|
||||
|
||||
add_template_value() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
local rgb
|
||||
|
||||
printf 's|{{ %s }}|%s|g\n' "$key" "$value" >>"$sed_script"
|
||||
printf 's|{{ %s_strip }}|%s|g\n' "$key" "${value#\#}" >>"$sed_script"
|
||||
|
||||
if [[ $value =~ ^#[0-9A-Fa-f]{6}$ ]]; then
|
||||
rgb=$(hex_to_rgb "$value")
|
||||
printf 's|{{ %s_rgb }}|%s|g\n' "$key" "$rgb" >>"$sed_script"
|
||||
fi
|
||||
}
|
||||
|
||||
add_mix_value() {
|
||||
local token="$1"
|
||||
local content fn start_key end_key amount start end value
|
||||
|
||||
content="${token#\{\{}"
|
||||
content="${content%\}\}}"
|
||||
read -r fn start_key end_key amount <<<"$content"
|
||||
|
||||
start="${THEME_COLORS[$start_key]:-}"
|
||||
end="${THEME_COLORS[$end_key]:-}"
|
||||
|
||||
[[ $start =~ ^#[0-9A-Fa-f]{6}$ && $end =~ ^#[0-9A-Fa-f]{6}$ ]] || return
|
||||
|
||||
value=$(mix_color "$start" "$end" "$amount")
|
||||
|
||||
case "$fn" in
|
||||
mix)
|
||||
;;
|
||||
mix_strip)
|
||||
value="${value#\#}"
|
||||
;;
|
||||
mix_rgb)
|
||||
value=$(hex_to_rgb "$value")
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
printf 's|%s|%s|g\n' "$token" "$value" >>"$sed_script"
|
||||
}
|
||||
|
||||
add_mix_values() {
|
||||
local tpl token
|
||||
local -A seen=()
|
||||
|
||||
for tpl in "${template_files[@]}"; do
|
||||
while IFS= read -r token; do
|
||||
[[ -n ${seen[$token]:-} ]] && continue
|
||||
seen[$token]=1
|
||||
add_mix_value "$token"
|
||||
done < <(grep -hEo '\{\{[[:space:]]*mix(_strip|_rgb)?[[:space:]]+[A-Za-z0-9_]+[[:space:]]+[A-Za-z0-9_]+[[:space:]]+[0-9]+([.][0-9]+)?%?[[:space:]]*\}\}' "$tpl" 2>/dev/null || true)
|
||||
done
|
||||
}
|
||||
|
||||
add_gradient_function_value() {
|
||||
local token="$1"
|
||||
local content fn key fallback value
|
||||
|
||||
content="${token#\{\{}"
|
||||
content="${content%\}\}}"
|
||||
read -r fn key fallback <<<"$content"
|
||||
|
||||
case "$fn" in
|
||||
hypr_gradient)
|
||||
value=$(hypr_gradient_value "$key" "$fallback")
|
||||
;;
|
||||
gradient_start)
|
||||
value=$(gradient_start_value "$key" "$fallback")
|
||||
;;
|
||||
shell_gradient)
|
||||
value=$(shell_gradient_value "$key" "$fallback")
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
printf 's|%s|%s|g\n' "$token" "$value" >>"$sed_script"
|
||||
}
|
||||
|
||||
add_gradient_function_values() {
|
||||
local tpl token
|
||||
local -A seen=()
|
||||
|
||||
for tpl in "${template_files[@]}"; do
|
||||
while IFS= read -r token; do
|
||||
[[ -n ${seen[$token]:-} ]] && continue
|
||||
seen[$token]=1
|
||||
add_gradient_function_value "$token"
|
||||
done < <(grep -hEo '\{\{[[:space:]]*(hypr_gradient|gradient_start|shell_gradient)[[:space:]]+[^}]+[[:space:]]*\}\}' "$tpl" 2>/dev/null || true)
|
||||
done
|
||||
}
|
||||
|
||||
strip_shell_section_header() {
|
||||
local section="$1"
|
||||
local file="$2"
|
||||
|
||||
awk -v section="$section" '
|
||||
BEGIN { skipping_header = 0 }
|
||||
/^[[:space:]]*\[[^]]+\][[:space:]]*($|#)/ {
|
||||
if ($0 ~ "^[[:space:]]*\\[" section "\\][[:space:]]*($|#)") {
|
||||
skipping_header = 1
|
||||
next
|
||||
}
|
||||
}
|
||||
{ print }
|
||||
' "$file"
|
||||
}
|
||||
|
||||
apply_shell_section_override() {
|
||||
local override="$1"
|
||||
local section tmp body
|
||||
|
||||
[[ -f $NEXT_THEME_DIR/shell.toml ]] || return
|
||||
[[ -f $override ]] || return
|
||||
|
||||
section=$(basename "$override")
|
||||
section="${section#shell.}"
|
||||
section="${section%.toml}"
|
||||
[[ $section =~ ^[A-Za-z0-9_-]+$ ]] || return
|
||||
|
||||
tmp=$(mktemp)
|
||||
body=$(mktemp)
|
||||
|
||||
strip_shell_section_header "$section" "$override" >"$body"
|
||||
|
||||
awk -v section="$section" -v body="$body" '
|
||||
function emit_override() {
|
||||
if (emitted) return
|
||||
print "[" section "]"
|
||||
while ((getline line < body) > 0) print line
|
||||
close(body)
|
||||
emitted = 1
|
||||
}
|
||||
|
||||
/^[[:space:]]*\[[^]]+\][[:space:]]*($|#)/ {
|
||||
if (in_section) {
|
||||
emit_override()
|
||||
in_section = 0
|
||||
}
|
||||
if ($0 ~ "^[[:space:]]*\\[" section "\\][[:space:]]*($|#)") {
|
||||
in_section = 1
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
!in_section { print }
|
||||
|
||||
END {
|
||||
if (in_section || !emitted) {
|
||||
if (NR > 0) print ""
|
||||
emit_override()
|
||||
}
|
||||
}
|
||||
' "$NEXT_THEME_DIR/shell.toml" >"$tmp"
|
||||
|
||||
mv "$tmp" "$NEXT_THEME_DIR/shell.toml"
|
||||
rm "$body"
|
||||
}
|
||||
|
||||
apply_shell_section_overrides() {
|
||||
local override
|
||||
|
||||
shopt -s nullglob
|
||||
for override in "$NEXT_THEME_DIR"/shell.*.toml; do
|
||||
[[ $(basename "$override") != "shell.toml" ]] || continue
|
||||
apply_shell_section_override "$override"
|
||||
done
|
||||
}
|
||||
|
||||
# Only generate dynamic templates for themes with a colors.toml definition
|
||||
if [[ -f $COLORS_FILE ]]; then
|
||||
sed_script=$(mktemp)
|
||||
|
||||
shopt -s nullglob
|
||||
template_files=("$USER_TEMPLATES_DIR"/*.tpl "$TEMPLATES_DIR"/*.tpl)
|
||||
|
||||
# Parsing and alias/fallback resolution (legacy colorN names, derived
|
||||
# shades, mode/theme_type) is shared with every other colors.toml consumer.
|
||||
while IFS=$'\t' read -r key value; do
|
||||
THEME_COLORS[$key]="$value"
|
||||
done < <(omarchy-theme-color --file "$COLORS_FILE" --all)
|
||||
|
||||
for key in "${!THEME_COLORS[@]}"; do
|
||||
add_template_value "$key" "${THEME_COLORS[$key]}"
|
||||
done
|
||||
|
||||
add_mix_values
|
||||
add_gradient_function_values
|
||||
|
||||
# Process user templates first, then built-in templates (user overrides built-in)
|
||||
for tpl in "${template_files[@]}"; do
|
||||
filename=$(basename "$tpl" .tpl)
|
||||
output_path="$NEXT_THEME_DIR/$filename"
|
||||
|
||||
# Don't overwrite configs already exists in the output directory (copied from theme specific folder)
|
||||
if [[ ! -f $output_path ]]; then
|
||||
sed -f "$sed_script" "$tpl" >"$output_path"
|
||||
fi
|
||||
done
|
||||
|
||||
rm "$sed_script"
|
||||
fi
|
||||
|
||||
apply_shell_section_overrides
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Sync Omarchy theme to VS Code, VSCodium, and Cursor
|
||||
# omarchy:hidden=true
|
||||
|
||||
VS_CODE_THEME="$HOME/.local/state/omarchy/current/theme/vscode.json"
|
||||
|
||||
set_theme() {
|
||||
local editor_cmd="$1"
|
||||
local settings_path="$2"
|
||||
|
||||
omarchy-cmd-present "$editor_cmd" || return 0
|
||||
|
||||
if [[ -f $VS_CODE_THEME ]]; then
|
||||
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
|
||||
extension=$(jq -r '.extension' "$VS_CODE_THEME")
|
||||
|
||||
if [[ -n $extension ]] && ! "$editor_cmd" --list-extensions 2>/dev/null | grep -Fxq "$extension"; then
|
||||
"$editor_cmd" --install-extension "$extension" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
mkdir -p "$(dirname "$settings_path")"
|
||||
[[ -f $settings_path ]] || printf '{\n}\n' >"$settings_path"
|
||||
|
||||
if ! grep -q '"workbench.colorTheme"' "$settings_path"; then
|
||||
sed -i --follow-symlinks -E '0,/\{/{s/\{/{\ "workbench.colorTheme": "",/}' "$settings_path"
|
||||
fi
|
||||
|
||||
sed -i --follow-symlinks -E \
|
||||
"s/(\"workbench.colorTheme\"[[:space:]]*:[[:space:]]*\")[^\"]*(\")/\1$theme_name\2/" \
|
||||
"$settings_path"
|
||||
elif [[ -f $settings_path ]]; then
|
||||
sed -i --follow-symlinks -E 's/\"workbench\.colorTheme\"[[:space:]]*:[^,}]*,?//' "$settings_path"
|
||||
fi
|
||||
}
|
||||
|
||||
! omarchy-toggle-enabled skip-vscode-theme-changes && set_theme "code" "$HOME/.config/Code/User/settings.json"
|
||||
! omarchy-toggle-enabled skip-vscode-insiders-theme-changes && set_theme "code-insiders" "$HOME/.config/Code - Insiders/User/settings.json"
|
||||
! omarchy-toggle-enabled skip-codium-theme-changes && set_theme "codium" "$HOME/.config/VSCodium/User/settings.json"
|
||||
! omarchy-toggle-enabled skip-cursor-theme-changes && set_theme "cursor" "$HOME/.config/Cursor/User/settings.json"
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Update user-installed git themes
|
||||
|
||||
for dir in ~/.config/omarchy/themes/*/; do
|
||||
if [[ -d $dir ]] && [[ ! -L ${dir%/} ]] && [[ -d $dir/.git ]]; then
|
||||
echo "Updating: $(basename "$dir")"
|
||||
git -C "$dir" pull
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user