feat: add omarchy theme template system with management scripts
- New default/themed/ templates (alacritty, btop, foot, ghostty, helix, hyprland, hyprlock, kitty, mako, obsidian, rofi, swayosd, tmux, walker, waybar, keyboard.rgb, gum.env, etc.) - Add omarchy-* theme management scripts (install, refresh, set, remove, update, bg-set, colors-from-alacritty, current, etc.) - Add omarchy restart/hook scripts (btop, hyprctl, hypridle, mako, tmux) - Add installer/environment.sh for shared env vars - Add 19 theme directories with colors.toml, vscode.json, backgrounds, and app-specific configs (catppuccin, everforest, gruvbox, nord, tokyo-night, rose-pine, etc.) - Update bing-wallpaper script to use new .config/omarchy path
This commit is contained in:
@@ -9,7 +9,7 @@ offset=0
|
||||
[[ "$1" =~ [1-9][0-9]*$ ]] && offset=$1
|
||||
|
||||
BACKGROUNDS_DIR="$HOME/Sync/Shared/wallpapers"
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.local/share/themes/current/background"
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background"
|
||||
|
||||
url_preffix="http://www.bing.com"
|
||||
xml_url="https://cn.bing.com/HPImageArchive.aspx?format=xml&idx=$offset&n=10&nc=1612409408851&pid=hp&FORM=BEHPTB&uhd=1&uhdwidth=3840&uhdheight=2160"
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/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
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/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
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/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
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Reload btop configuration (used by the Omarchy theme switching).
|
||||
|
||||
pkill -SIGUSR2 btop
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Reload hyprland configuration (used by the Omarchy theme switching).
|
||||
|
||||
hyprctl reload >/dev/null
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Restart the hypridle service (used for idle detection and auto-lock).
|
||||
|
||||
omarchy-restart-app hypridle
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Reload mako configuration (used by the Omarchy theme switching).
|
||||
|
||||
makoctl reload
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/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
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/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/.config/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 &
|
||||
Executable
+211
@@ -0,0 +1,211 @@
|
||||
#!/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
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Show current theme
|
||||
# omarchy:examples=omarchy theme current
|
||||
|
||||
THEME_NAME_PATH="$HOME/.config/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
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/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
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Refresh the current theme from its templates.
|
||||
|
||||
THEME_NAME_PATH="$HOME/.config/omarchy/current/theme.name"
|
||||
|
||||
if [[ -f $THEME_NAME_PATH ]]; then
|
||||
OMARCHY_THEME_SKIP_BACKGROUND=1 omarchy-theme-set "$(cat $THEME_NAME_PATH)"
|
||||
fi
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/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/.config/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"
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme color to Chromium, Chrome, Edge, and Brave
|
||||
# omarchy:hidden=true
|
||||
|
||||
CHROMIUM_THEME=~/.config/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
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply current Omarchy theme colors to running Foot terminals
|
||||
# omarchy:hidden=true
|
||||
|
||||
foot_theme=~/.config/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
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme to GNOME color mode and icon settings
|
||||
# omarchy:hidden=true
|
||||
|
||||
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
|
||||
|
||||
# Change gnome icon theme color
|
||||
GNOME_ICONS_THEME=~/.config/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
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/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
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme keyboard color to ASUS ROG keyboards
|
||||
# omarchy:hidden=true
|
||||
|
||||
ASUSCTL_THEME=~/.config/omarchy/current/theme/keyboard.rgb
|
||||
|
||||
if omarchy-cmd-present asusctl; then
|
||||
asusctl aura effect static -c $(sed 's/^#//' $ASUSCTL_THEME)
|
||||
fi
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Apply the current theme keyboard color to Framework Laptop 16 keyboards
|
||||
# omarchy:hidden=true
|
||||
|
||||
FRAMEWORK16_THEME=~/.config/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
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Sync Omarchy theme to all Obsidian vaults
|
||||
# omarchy:hidden=true
|
||||
|
||||
CURRENT_THEME_DIR="$HOME/.config/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
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/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/.config/omarchy/current/next-theme"
|
||||
COLORS_FILE="$NEXT_THEME_DIR/colors.toml"
|
||||
|
||||
# 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}"
|
||||
}
|
||||
|
||||
# Only generate dynamic templates for themes with a colors.toml definition
|
||||
if [[ -f $COLORS_FILE ]]; then
|
||||
sed_script=$(mktemp)
|
||||
|
||||
while IFS='=' read -r key value; do
|
||||
key="${key//[\"\' ]/}" # strip quotes and spaces from key
|
||||
[[ $key && $key != \#* ]] || continue # skip empty lines and comments
|
||||
value="${value#*[\"\']}"
|
||||
value="${value%%[\"\']*}" # extract value between quotes (ignores inline comments)
|
||||
|
||||
printf 's|{{ %s }}|%s|g\n' "$key" "$value" # {{ key }} -> value
|
||||
printf 's|{{ %s_strip }}|%s|g\n' "$key" "${value#\#}" # {{ key_strip }} -> value without leading #
|
||||
if [[ $value =~ ^# ]]; then
|
||||
rgb=$(hex_to_rgb "$value")
|
||||
echo "s|{{ ${key}_rgb }}|${rgb}|g"
|
||||
fi
|
||||
done <"$COLORS_FILE" >"$sed_script"
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
# Process user templates first, then built-in templates (user overrides built-in)
|
||||
for tpl in "$USER_TEMPLATES_DIR"/*.tpl "$TEMPLATES_DIR"/*.tpl; 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
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Sync Omarchy theme to VS Code, VSCodium, and Cursor
|
||||
# omarchy:hidden=true
|
||||
|
||||
VS_CODE_THEME="$HOME/.config/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"
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/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