Add Pi theme based on system theme
Based entirely on the work of @robzolkos in #5711. That attempt was adapted to better fit the standard templating system while also adding color mixing for use in other themes.
This commit is contained in:
@@ -173,6 +173,7 @@ post_theme_commands=(
|
||||
omarchy-restart-helix
|
||||
omarchy-theme-set-foot
|
||||
omarchy-theme-set-gnome
|
||||
omarchy-theme-set-pi
|
||||
omarchy-theme-set-browser
|
||||
omarchy-theme-set-vscode
|
||||
omarchy-theme-set-obsidian
|
||||
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Sync the generated Omarchy Pi theme
|
||||
# omarchy:args=[--activate]
|
||||
# omarchy:hidden=true
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
|
||||
PI_SOURCE_PATH="$CURRENT_THEME_PATH/pi.json"
|
||||
PI_AGENT_DIR="$HOME/.pi/agent"
|
||||
PI_THEME_DIR="$PI_AGENT_DIR/themes"
|
||||
PI_THEME_PATH="$PI_THEME_DIR/omarchy-system.json"
|
||||
PI_SETTINGS_PATH="$PI_AGENT_DIR/settings.json"
|
||||
PI_ACTIVATE=0
|
||||
|
||||
usage() {
|
||||
echo "Usage: omarchy-theme-set-pi [--activate]"
|
||||
}
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--activate)
|
||||
PI_ACTIVATE=1
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -f $PI_SOURCE_PATH ]]; then
|
||||
if (( PI_ACTIVATE == 1 )); then
|
||||
echo "Pi theme source missing: $PI_SOURCE_PATH" >&2
|
||||
echo "Run omarchy-theme-refresh after selecting an Omarchy theme." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if (( PI_ACTIVATE == 0 )) && [[ ! -d $PI_AGENT_DIR ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
write_setting_theme() {
|
||||
local tmp
|
||||
|
||||
mkdir -p "$PI_AGENT_DIR"
|
||||
|
||||
if [[ -f $PI_SETTINGS_PATH ]]; then
|
||||
tmp=$(mktemp "$PI_SETTINGS_PATH.XXXXXX")
|
||||
jq '.theme = "omarchy-system"' "$PI_SETTINGS_PATH" >"$tmp"
|
||||
mv "$tmp" "$PI_SETTINGS_PATH"
|
||||
else
|
||||
cat >"$PI_SETTINGS_PATH" <<EOF
|
||||
{
|
||||
"theme": "omarchy-system"
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
mkdir -p "$PI_THEME_DIR"
|
||||
tmp=$(mktemp "$PI_THEME_PATH.XXXXXX")
|
||||
cp "$PI_SOURCE_PATH" "$tmp"
|
||||
mv "$tmp" "$PI_THEME_PATH"
|
||||
|
||||
if (( PI_ACTIVATE == 1 )); then
|
||||
write_setting_theme
|
||||
fi
|
||||
Reference in New Issue
Block a user