Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion bin/omarchy-toggle-bar
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions test/acceptance.d/session-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 21 additions & 6 deletions test/shell.d/toggle-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"