Files
omarchycn/bin/omarchy-style-bar-position
T
2026-05-14 02:21:47 -04:00

40 lines
844 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Set bar position
# omarchy:args=<top|bottom|left|right>
# omarchy:examples=omarchy-style-bar-position top | omarchy style bar position bottom
set -e
CONFIG_FILE="$HOME/.config/omarchy/bar.json"
position=$1
if [[ ! $position =~ ^(top|bottom|left|right)$ ]]; then
echo "Usage: omarchy-style-bar-position top|bottom|left|right" >&2
exit 1
fi
mkdir -p "$(dirname "$CONFIG_FILE")"
python3 - "$CONFIG_FILE" "$position" <<'PY'
import json
import os
import sys
path, position = sys.argv[1], sys.argv[2]
try:
with open(path) as file:
data = json.load(file)
if not isinstance(data, dict):
data = {}
except (FileNotFoundError, json.JSONDecodeError):
data = {}
data["position"] = position
with open(path, "w") as file:
json.dump(data, file, indent=2)
file.write("\n")
PY
omarchy-restart-bar