diff --git a/bin/omarchy-toggle-bar b/bin/omarchy-toggle-bar index be18a647299..3d359a61297 100755 --- a/bin/omarchy-toggle-bar +++ b/bin/omarchy-toggle-bar @@ -4,7 +4,23 @@ # omarchy:args=[toggle|on|off] # omarchy:examples=omarchy toggle bar | omarchy toggle bar off | omarchy toggle bar on -omarchy-toggle bar-off "${1:-toggle}" +# The flag is named for the off state, so the user-facing on and off run the +# other way round: `bar on` lifts `bar-off` and `bar off` sets it. +case "${1:-toggle}" in + toggle) + omarchy-toggle bar-off + ;; + on) + omarchy-toggle bar-off off + ;; + off) + omarchy-toggle bar-off on + ;; + *) + echo "Usage: omarchy-toggle-bar [toggle|on|off]" >&2 + exit 1 + ;; +esac # The shell's watch on the toggles directory can miss flag changes that land in # quick succession, stranding the bar off screen until the shell restarts. diff --git a/test/acceptance.d/session-test.sh b/test/acceptance.d/session-test.sh index 16c3171df26..e2720a03d39 100644 --- a/test/acceptance.d/session-test.sh +++ b/test/acceptance.d/session-test.sh @@ -30,16 +30,16 @@ wait_until "background layer is on screen" 30 layer_on_screen "omarchy-backgroun # Hiding parks the bar off-screen without unmapping its layer surface, and # revealing brings that same surface back on-screen. restore_bar_visibility() { - omarchy-toggle-bar off >/dev/null 2>&1 || true + omarchy-toggle-bar on >/dev/null 2>&1 || true } trap restore_bar_visibility EXIT -omarchy-toggle-bar on +omarchy-toggle-bar off wait_until "hidden bar layer stays mapped" 15 layer_present "omarchy-bar" wait_until "hidden bar layer parks off screen" 15 layer_off_screen "omarchy-bar" screenshot "success-bar-hidden" -omarchy-toggle-bar off +omarchy-toggle-bar on wait_until "revealed bar layer returns on screen" 15 layer_on_screen "omarchy-bar" screenshot "success-bar-revealed" trap - EXIT diff --git a/test/shell.d/toggle-test.sh b/test/shell.d/toggle-test.sh index 7ab3a54332c..693848b77f8 100644 --- a/test/shell.d/toggle-test.sh +++ b/test/shell.d/toggle-test.sh @@ -40,14 +40,29 @@ HOME="$test_home" omarchy-toggle example toggle [[ ! -f $flag ]] || fail "generic toggle flips enabled state off" pass "generic toggle flips enabled state off" +HOME="$test_home" omarchy-toggle-bar off +[[ -f $bar_flag ]] || fail "bar off sets the bar-off flag" +pass "bar off sets the bar-off flag" + +HOME="$test_home" omarchy-toggle-bar off +[[ -f $bar_flag ]] || fail "bar off is idempotent" +pass "bar off is idempotent" + HOME="$test_home" omarchy-toggle-bar on -[[ -f $bar_flag ]] || fail "bar on enables bar-off toggle" -pass "bar on enables bar-off toggle" +[[ ! -f $bar_flag ]] || fail "bar on lifts the bar-off flag" +pass "bar on lifts the bar-off flag" HOME="$test_home" omarchy-toggle-bar on -[[ -f $bar_flag ]] || fail "bar on is idempotent" +[[ ! -f $bar_flag ]] || fail "bar on is idempotent" pass "bar on is idempotent" -HOME="$test_home" omarchy-toggle-bar off -[[ ! -f $bar_flag ]] || fail "bar off disables bar-off toggle" -pass "bar off disables bar-off toggle" +HOME="$test_home" omarchy-toggle-bar +[[ -f $bar_flag ]] || fail "bar toggle hides a visible bar" +pass "bar toggle hides a visible bar" + +HOME="$test_home" omarchy-toggle-bar toggle +[[ ! -f $bar_flag ]] || fail "bar toggle reveals a hidden bar" +pass "bar toggle reveals a hidden bar" + +HOME="$test_home" omarchy-toggle-bar sideways 2>/dev/null && fail "bar rejects an unknown action" +pass "bar rejects an unknown action"