Move current theme state to local state

This commit is contained in:
Ryan Hughes
2026-06-09 19:48:37 -04:00
parent 29c4a20a86
commit 0f5e81143e
45 changed files with 261 additions and 72 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ omarchy-pkg-add helix
mkdir -p ~/.config/helix/themes
# Symlink the rendered Omarchy theme so Helix tracks the active theme
ln -sf ~/.config/omarchy/current/theme/helix.toml ~/.config/helix/themes/omarchy.toml
ln -sf "$HOME/.local/state/omarchy/current/theme/helix.toml" ~/.config/helix/themes/omarchy.toml
# Only seed a config.toml if the user does not already have one
if [[ ! -f ~/.config/helix/config.toml ]]; then
@@ -18,7 +18,7 @@ EOF
fi
# Ensure the symlink target exists for users whose current theme predates this template
if [[ ! -e ~/.config/omarchy/current/theme/helix.toml ]]; then
if [[ ! -e $HOME/.local/state/omarchy/current/theme/helix.toml ]]; then
omarchy-theme-refresh
fi
+1 -1
View File
@@ -2,7 +2,7 @@
# omarchy:summary=Preview a Plymouth boot screen with custom colors and logo
# omarchy:args=<background-hex> <text-hex> <path-to-logo.png> <output-path>
# omarchy:examples=omarchy plymouth preview '#1d2021' '#ebdbb2' ~/.config/omarchy/current/theme/plymouth/logo.png /tmp/plymouth-preview.png
# omarchy:examples=omarchy plymouth preview '#1d2021' '#ebdbb2' ~/.local/state/omarchy/current/theme/plymouth/logo.png /tmp/plymouth-preview.png
# Render a Plymouth login-screen preview PNG by compositing the staged omarchy
# theme assets (recolored with the given text color) onto the background.
+1 -1
View File
@@ -2,7 +2,7 @@
# omarchy:summary=Set the Plymouth boot theme colors and logo
# omarchy:args=<background-hex> <text-hex> <path-to-logo.png>
# omarchy:examples=omarchy plymouth set '#1d2021' '#ebdbb2' ~/.config/omarchy/current/theme/plymouth/logo.png
# omarchy:examples=omarchy plymouth set '#1d2021' '#ebdbb2' ~/.local/state/omarchy/current/theme/plymouth/logo.png
# omarchy:requires-sudo=true
# Configure the Plymouth boot theme with a custom background color, text color, and logo.
+1 -1
View File
@@ -75,7 +75,7 @@ valid_hex "$background_color" || fallback
omarchy-cmd-present magick || fallback
if [[ -z $background_path ]]; then
background_path=$(readlink -f "$HOME/.config/omarchy/current/background" 2>/dev/null || true)
background_path=$(readlink -f "$HOME/.local/state/omarchy/current/background" 2>/dev/null || true)
fi
[[ -f $background_path ]] || fallback
+2 -2
View File
@@ -2,9 +2,9 @@
# omarchy:summary=Cache background switcher thumbnails for the current theme
theme_name=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null)
theme_name=$(cat "$HOME/.local/state/omarchy/current/theme.name" 2>/dev/null)
omarchy-menu-images \
--cache-only \
"$HOME/.config/omarchy/current/theme/backgrounds" \
"$HOME/.local/state/omarchy/current/theme/backgrounds" \
"$HOME/.config/omarchy/backgrounds/$theme_name"
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Show current background
# omarchy:examples=omarchy theme bg current
BACKGROUND_PATH=$(readlink -f "$HOME/.config/omarchy/current/background" 2>/dev/null)
BACKGROUND_PATH=$(readlink -f "$HOME/.local/state/omarchy/current/background" 2>/dev/null)
if [[ -n $BACKGROUND_PATH ]]; then
basename -- "$BACKGROUND_PATH" | perl -pe 's/\.[^.]+$//; s/^\d+-//; s/-/ /g; s/\b(\w)/\U$1/g'
+1 -1
View File
@@ -2,7 +2,7 @@
# omarchy:summary=Open the current theme's user background folder
CURRENT_THEME_NAME=$(cat "$HOME/.config/omarchy/current/theme.name")
CURRENT_THEME_NAME=$(cat "$HOME/.local/state/omarchy/current/theme.name")
THEME_USER_BACKGROUNDS="$HOME/.config/omarchy/backgrounds/$CURRENT_THEME_NAME"
mkdir -p "$THEME_USER_BACKGROUNDS"
+3 -3
View File
@@ -3,10 +3,10 @@
# omarchy:summary=Cycle to the next background for the current theme
# omarchy:examples=omarchy theme bg next
THEME_NAME=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null)
THEME_BACKGROUNDS_PATH="$HOME/.config/omarchy/current/theme/backgrounds/"
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/.config/omarchy/current/background"
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 \
+1 -1
View File
@@ -10,7 +10,7 @@ if [[ -z $1 ]]; then
fi
BACKGROUND="$(realpath "$1")"
CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background"
CURRENT_BACKGROUND_LINK="$HOME/.local/state/omarchy/current/background"
if [[ ! -f $BACKGROUND ]]; then
echo "File does not exist: $BACKGROUND" >&2
+3 -3
View File
@@ -5,10 +5,10 @@
# omarchy:name=bg-switcher
# omarchy:aliases=omarchy background
theme_name=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null)
current_background=$(readlink -f "$HOME/.config/omarchy/current/background" 2>/dev/null)
theme_name=$(cat "$HOME/.local/state/omarchy/current/theme.name" 2>/dev/null)
current_background=$(readlink -f "$HOME/.local/state/omarchy/current/background" 2>/dev/null)
omarchy-menu-images \
--selected "$current_background" \
"$HOME/.config/omarchy/current/theme/backgrounds" \
"$HOME/.local/state/omarchy/current/theme/backgrounds" \
"$HOME/.config/omarchy/backgrounds/$theme_name"
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Show current theme
# omarchy:examples=omarchy theme current
THEME_NAME_PATH="$HOME/.config/omarchy/current/theme.name"
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'
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Print OSC sequences for an Omarchy color theme
# omarchy:hidden=true
theme="${1:-$HOME/.config/omarchy/current/theme/colors.toml}"
theme="${1:-$HOME/.local/state/omarchy/current/theme/colors.toml}"
[[ -f $theme ]] || exit 0
+1 -1
View File
@@ -2,7 +2,7 @@
# omarchy:summary=Refresh the current theme from its templates.
THEME_NAME_PATH="$HOME/.config/omarchy/current/theme.name"
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)"
-1
View File
@@ -19,7 +19,6 @@ else
fi
THEMES_DIR="$HOME/.config/omarchy/themes"
CURRENT_DIR="$HOME/.config/omarchy/current"
THEME_PATH="$THEMES_DIR/$THEME_NAME"
# Ensure a theme was set
+4 -4
View File
@@ -9,9 +9,9 @@ if [[ -z $1 ]]; then
exit 1
fi
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
NEXT_THEME_PATH="$HOME/.config/omarchy/current/next-theme"
CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background"
CURRENT_THEME_PATH="$HOME/.local/state/omarchy/current/theme"
NEXT_THEME_PATH="$HOME/.local/state/omarchy/current/next-theme"
CURRENT_BACKGROUND_LINK="$HOME/.local/state/omarchy/current/background"
BACKGROUND_TRANSITION_CACHE="$HOME/.cache/omarchy/background-transitions"
THEME_SET_LOCK="${XDG_RUNTIME_DIR:-/tmp}/omarchy-theme-set.lock"
USER_THEMES_PATH="$HOME/.config/omarchy/themes"
@@ -165,7 +165,7 @@ rm -rf "$CURRENT_THEME_PATH"
mv "$NEXT_THEME_PATH" "$CURRENT_THEME_PATH"
# Store theme name for reference
echo "$THEME_NAME" >"$HOME/.config/omarchy/current/theme.name"
echo "$THEME_NAME" >"$HOME/.local/state/omarchy/current/theme.name"
# Make the running shell pick up the new palette immediately while the rest of
# the theme hooks run.
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Apply the current theme color to Chromium, Chrome, Edge, and Brave
# omarchy:hidden=true
CHROMIUM_THEME=~/.config/omarchy/current/theme/chromium.theme
CHROMIUM_THEME=$HOME/.local/state/omarchy/current/theme/chromium.theme
if [[ -f $CHROMIUM_THEME ]]; then
THEME_RGB_COLOR=$(<$CHROMIUM_THEME)
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Apply current Omarchy theme colors to running Foot terminals
# omarchy:hidden=true
colors_toml=~/.config/omarchy/current/theme/colors.toml
colors_toml=$HOME/.local/state/omarchy/current/theme/colors.toml
if [[ ! -f $colors_toml ]] || ! pgrep -x foot >/dev/null; then
exit 0
+2 -2
View File
@@ -10,7 +10,7 @@ if [[ -z ${DBUS_SESSION_BUS_ADDRESS:-} ]]; then
exit 0
fi
THEME_DIR=~/.config/omarchy/current/theme
THEME_DIR=$HOME/.local/state/omarchy/current/theme
COLORS_FILE="$THEME_DIR/colors.toml"
# In-tree light themes now declare `mode = "light"` in colors.toml instead of
@@ -50,7 +50,7 @@ else
fi
# Change gnome icon theme color
GNOME_ICONS_THEME=~/.config/omarchy/current/theme/icons.theme
GNOME_ICONS_THEME=$HOME/.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
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Apply the current theme keyboard color to ASUS ROG keyboards
# omarchy:hidden=true
ASUSCTL_THEME=~/.config/omarchy/current/theme/keyboard.rgb
ASUSCTL_THEME=$HOME/.local/state/omarchy/current/theme/keyboard.rgb
if omarchy-cmd-present asusctl; then
asusctl aura effect static -c $(sed 's/^#//' $ASUSCTL_THEME)
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Apply the current theme keyboard color to Framework Laptop 16 keyboards
# omarchy:hidden=true
FRAMEWORK16_THEME=~/.config/omarchy/current/theme/keyboard.rgb
FRAMEWORK16_THEME=$HOME/.local/state/omarchy/current/theme/keyboard.rgb
if omarchy-cmd-present qmk_hid && [[ -f $FRAMEWORK16_THEME ]]; then
hex=$(cat "$FRAMEWORK16_THEME")
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Sync Omarchy theme to all Obsidian vaults
# omarchy:hidden=true
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
CURRENT_THEME_DIR="$HOME/.local/state/omarchy/current/theme"
[[ -f $CURRENT_THEME_DIR/obsidian.css ]] || exit 0
+1 -1
View File
@@ -6,7 +6,7 @@
set -euo pipefail
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
CURRENT_THEME_PATH="$HOME/.local/state/omarchy/current/theme"
PI_SOURCE_PATH="$CURRENT_THEME_PATH/pi.json"
PI_AGENT_DIR="$HOME/.pi/agent"
PI_THEME_DIR="$PI_AGENT_DIR/themes"
+1 -1
View File
@@ -5,7 +5,7 @@
TEMPLATES_DIR="$OMARCHY_PATH/default/themed"
USER_TEMPLATES_DIR="$HOME/.config/omarchy/themed"
NEXT_THEME_DIR="$HOME/.config/omarchy/current/next-theme"
NEXT_THEME_DIR="$HOME/.local/state/omarchy/current/next-theme"
COLORS_FILE="$NEXT_THEME_DIR/colors.toml"
declare -A THEME_COLORS
+1 -1
View File
@@ -3,7 +3,7 @@
# omarchy:summary=Sync current Omarchy theme environment into tmux
# omarchy:hidden=true
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
CURRENT_THEME_PATH="$HOME/.local/state/omarchy/current/theme"
GUM_ENV="$CURRENT_THEME_PATH/gum_env.lua"
COLORS_TOML="$CURRENT_THEME_PATH/colors.toml"
+2 -2
View File
@@ -3,8 +3,8 @@
# omarchy:summary=Sync Omarchy theme to VS Code, VSCodium, and Cursor
# omarchy:hidden=true
VS_CODE_THEME_DESCRIPTOR="$HOME/.config/omarchy/current/theme/vscode.json"
GENERATED_THEME="$HOME/.config/omarchy/current/theme/vscode-theme.json"
VS_CODE_THEME_DESCRIPTOR="$HOME/.local/state/omarchy/current/theme/vscode.json"
GENERATED_THEME="$HOME/.local/state/omarchy/current/theme/vscode-theme.json"
GENERATED_EXTENSION_NAME="omarchy-theme"
GENERATED_EXTENSION_ID="local.$GENERATED_EXTENSION_NAME"
GENERATED_EXTENSION_VERSION="1.0.0"
+1 -1
View File
@@ -102,7 +102,7 @@ if [[ ! -f $fast_signature_file ]] || ! cmp -s "$fast_signature_file" <(printf '
printf '%s' "$fast_signature" >"$fast_signature_file"
fi
current_theme=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null)
current_theme=$(cat "$HOME/.local/state/omarchy/current/theme.name" 2>/dev/null)
selected_preview=""
for extension in png jpg jpeg webp gif bmp; do
if [[ -e $preview_dir/$current_theme.$extension ]]; then
+68 -7
View File
@@ -1873,10 +1873,53 @@ EOF
fi
mkdir -p "$HOME/.config/omarchy/themes" "$HOME/.config/btop/themes"
ln -snf "$HOME/.config/omarchy/current/theme/btop.theme" "$HOME/.config/btop/themes/current.theme"
if [[ ! -e $HOME/.config/omarchy/current/background && -d $HOME/.config/omarchy/current/theme/backgrounds ]]; then
background=$(find "$HOME/.config/omarchy/current/theme/backgrounds" -maxdepth 1 -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \) | sort | head -n1)
[[ -n ${background:-} ]] && ln -snf "$background" "$HOME/.config/omarchy/current/background"
legacy_current_dir="$HOME/.config/omarchy/current"
current_state_dir="$HOME/.local/state/omarchy/current"
if [[ -e $legacy_current_dir || -L $legacy_current_dir ]]; then
mkdir -p "$HOME/.local/state/omarchy"
if [[ ! -e $current_state_dir && ! -L $current_state_dir ]]; then
mv "$legacy_current_dir" "$current_state_dir"
else
if [[ -d $legacy_current_dir && -d $current_state_dir ]]; then
cp -an "$legacy_current_dir/." "$current_state_dir/" 2>/dev/null || true
fi
rm -rf "$legacy_current_dir"
fi
fi
replace_legacy_current_path() {
local file="$1"
[[ -f $file ]] || return 0
python3 - "$file" "$HOME" <<'PY'
from pathlib import Path
import sys
path = Path(sys.argv[1])
home = sys.argv[2]
text = path.read_text()
replacements = {
f"{home}/.config/omarchy/current": f"{home}/.local/state/omarchy/current",
"~/.config/omarchy/current": "~/.local/state/omarchy/current",
"../omarchy/current": "../../.local/state/omarchy/current",
}
for old, new in replacements.items():
text = text.replace(old, new)
path.write_text(text)
PY
}
for file in \
"$HOME/.config/alacritty/alacritty.toml" \
"$HOME/.config/foot/foot.ini" \
"$HOME/.config/ghostty/config" \
"$HOME/.config/hypr/hyprland.conf" \
"$HOME/.config/hyprland-preview-share-picker/config.yaml" \
"$HOME/.config/kitty/kitty.conf"; do
replace_legacy_current_path "$file"
done
ln -snf "$HOME/.local/state/omarchy/current/theme/btop.theme" "$HOME/.config/btop/themes/current.theme"
if [[ ! -e $HOME/.local/state/omarchy/current/background && -d $HOME/.local/state/omarchy/current/theme/backgrounds ]]; then
background=$(find "$HOME/.local/state/omarchy/current/theme/backgrounds" -maxdepth 1 -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \) | sort | head -n1)
[[ -n ${background:-} ]] && ln -snf "$background" "$HOME/.local/state/omarchy/current/background"
fi
mkdir -p "$HOME/.config/wireplumber/wireplumber.conf.d"
@@ -2037,9 +2080,20 @@ write_legacy_theme_hyprland_conf() {
set -euo pipefail
hyprland_conf="$HOME/.config/hypr/hyprland.conf"
[[ -f $hyprland_conf ]] || exit 0
python3 - "$hyprland_conf" "$HOME" <<'PY'
from pathlib import Path
import sys
path = Path(sys.argv[1])
home = sys.argv[2]
text = path.read_text()
text = text.replace(f"{home}/.config/omarchy/current", f"{home}/.local/state/omarchy/current")
text = text.replace("~/.config/omarchy/current", "~/.local/state/omarchy/current")
path.write_text(text)
PY
grep -q 'current/theme/hyprland.conf' "$hyprland_conf" || exit 0
theme_dir="$HOME/.config/omarchy/current/theme"
theme_dir="$HOME/.local/state/omarchy/current/theme"
colors="$theme_dir/colors.toml"
target="$theme_dir/hyprland.conf"
mkdir -p "$theme_dir"
@@ -2068,14 +2122,21 @@ refresh_current_theme_after_upgrade() {
theme_name=$(run_as_user env HOME="$target_home" bash -c '
set -euo pipefail
theme_name_path="$HOME/.config/omarchy/current/theme.name"
current_theme_path="$HOME/.config/omarchy/current/theme"
theme_name_path="$HOME/.local/state/omarchy/current/theme.name"
current_theme_path="$HOME/.local/state/omarchy/current/theme"
legacy_theme_name_path="$HOME/.config/omarchy/current/theme.name"
legacy_current_theme_path="$HOME/.config/omarchy/current/theme"
if [[ -f $theme_name_path ]]; then
read -r theme_name <"$theme_name_path" || true
printf "%s" "${theme_name:-}"
elif [[ -f $legacy_theme_name_path ]]; then
read -r theme_name <"$legacy_theme_name_path" || true
printf "%s" "${theme_name:-}"
elif [[ -L $current_theme_path ]]; then
basename -- "$(readlink "$current_theme_path")"
elif [[ -L $legacy_current_theme_path ]]; then
basename -- "$(readlink "$legacy_current_theme_path")"
else
printf ""
fi