diff --git a/bin/omarchy-bar b/bin/omarchy-bar index 820bff9a..d354645b 100755 --- a/bin/omarchy-bar +++ b/bin/omarchy-bar @@ -2,7 +2,7 @@ # omarchy:summary=Mutate the user shell.json bar layout, active bar option, and bar settings # omarchy:group=bar -# omarchy:args=show | layout [--json] | list [--json] [--all] | options [--json] | use | reset | add [plugin] [placement] | move [placement] | remove [plugin] [placement] | set [--json] [placement] | replace | position | transparent | settings +# omarchy:args=show | layout [--json] | list [--json] [--all] | options [--json] | use | reset | defaults | add [plugin] [placement] | move [placement] | remove [plugin] [placement] | set [--json] [placement] | replace | position | transparent | settings # omarchy:examples=omarchy bar show | omarchy bar list | omarchy bar add omarchy.tailscale | omarchy bar add omarchy.clock --section center --before omarchy.weather | omarchy bar move omarchy.clock --section center --index 0 | omarchy bar remove omarchy.tailscale | omarchy bar set omarchy.clock format HH:mm | omarchy bar use local.neon-bar | omarchy bar position top | omarchy bar transparent true set -euo pipefail @@ -24,6 +24,7 @@ Inspect: Select: use Use a bar option as the active bar reset Return to the built-in Omarchy bar + defaults Restore the default bar and service widgets Edit layout: add [placement] Add a bar widget @@ -68,6 +69,7 @@ Examples: omarchy bar set omarchy.indicators items '["Dnd","NightLight"]' --json omarchy bar use local.neon-bar omarchy bar reset + omarchy bar defaults omarchy bar position top omarchy bar transparent true USAGE @@ -504,6 +506,25 @@ cmd_reset() { echo "Reset to the built-in Omarchy bar" } +cmd_defaults() { + local service + local services=(dropbox tailscale) + + (( $# == 0 )) || fail "defaults does not take arguments" + require_omarchy_path + [[ -s $DEFAULTS_FILE ]] || fail "could not find bar defaults" + + commit "$JQ_DEFS $NORMALIZE | .bar = \$defaults[0].bar" --slurpfile defaults "$DEFAULTS_FILE" + + for service in "${services[@]}"; do + if "omarchy-installed-service-$service"; then + cmd_add "omarchy.$service" + fi + done + + echo "Restored the default Omarchy bar" +} + # --------------------------------------------------------------- commands: edit cmd_add() { @@ -812,6 +833,9 @@ case "$command" in reset) cmd_reset "$@" ;; + defaults) + cmd_defaults "$@" + ;; add) cmd_add "$@" ;; diff --git a/bin/omarchy-refresh-shell b/bin/omarchy-refresh-shell index 13dc68fb..d7315567 100755 --- a/bin/omarchy-refresh-shell +++ b/bin/omarchy-refresh-shell @@ -6,13 +6,6 @@ set -euo pipefail omarchy-refresh-config omarchy/shell.json - -if omarchy-installed-service-dropbox; then - omarchy-bar add omarchy.dropbox -fi - -if omarchy-installed-service-tailscale; then - omarchy-bar add omarchy.tailscale -fi +omarchy-bar defaults omarchy-restart-shell diff --git a/bin/omarchy-upgrade-to-quattro b/bin/omarchy-upgrade-to-quattro index ada559e9..491ef374 100755 --- a/bin/omarchy-upgrade-to-quattro +++ b/bin/omarchy-upgrade-to-quattro @@ -2326,6 +2326,13 @@ cleanup_legacy_user_paths apply_system_transition suppress_hyprland_config_reload apply_user_transition +run_as_user env \ + HOME="$target_home" \ + USER="$target_user" \ + LOGNAME="$target_user" \ + OMARCHY_PATH=/usr/share/omarchy \ + PATH="$package_path" \ + omarchy-bar defaults cleanup_retired_services ensure_sleep_lock_service remove_retired_default_packages diff --git a/test/shell.d/config-test.sh b/test/shell.d/config-test.sh index 904b3a2e..ae6f2316 100755 --- a/test/shell.d/config-test.sh +++ b/test/shell.d/config-test.sh @@ -343,6 +343,21 @@ SH chmod +x "$mock_bin"/* mock_path="$mock_bin:$ROOT/bin:$PATH" +HOME="$TMPDIR/home" OMARCHY_PATH="$ROOT" PATH="$mock_path" OMARCHY_TEST_DROPBOX=0 OMARCHY_TEST_TAILSCALE=0 omarchy-bar defaults +jq -e --slurpfile defaults "$ROOT/config/omarchy/shell.json" ' + .bar == $defaults[0].bar and + .plugins == [] +' "$TMPDIR/home/.config/omarchy/shell.json" >/dev/null +pass "bar defaults restores the stock bar" + +HOME="$TMPDIR/home" OMARCHY_PATH="$ROOT" PATH="$mock_path" OMARCHY_TEST_DROPBOX=1 OMARCHY_TEST_TAILSCALE=1 omarchy-bar defaults +jq -e ' + def ids: map(.id // .); + (.bar.layout.right | ids | index("omarchy.dropbox") != null) and + (.bar.layout.right | ids | index("omarchy.tailscale") != null) +' "$TMPDIR/home/.config/omarchy/shell.json" >/dev/null +pass "bar defaults adds widgets for running optional services" + HOME="$TMPDIR/home" OMARCHY_PATH="$ROOT" PATH="$mock_path" OMARCHY_TEST_DROPBOX=0 OMARCHY_TEST_TAILSCALE=0 omarchy-refresh-shell jq -e ' def ids: map(.id // .); diff --git a/test/shell.d/upgrade-to-quattro-test.sh b/test/shell.d/upgrade-to-quattro-test.sh index d4b750e7..036d3d31 100644 --- a/test/shell.d/upgrade-to-quattro-test.sh +++ b/test/shell.d/upgrade-to-quattro-test.sh @@ -47,3 +47,6 @@ grep -F 'systemd-networkd.service' "$upgrade_to_quattro" >/dev/null grep -F 'systemd-networkd.socket' "$upgrade_to_quattro" >/dev/null grep -F 'systemd-networkd-resolve-hook.socket' "$upgrade_to_quattro" >/dev/null pass "Omarchy 4 upgrade retires systemd-networkd for NetworkManager" + +grep -F 'omarchy-bar defaults' "$upgrade_to_quattro" >/dev/null +pass "Omarchy 4 upgrade restores service-aware bar defaults"