/ de-omarchy / bin / omarchy-bar-style-cycle
swadhinbiswas Add bar style presets: 10 themes, live set/cycle over shell IPC, omarchy bar style CLI · 8/24/2026
fe09911
33 lines · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

# omarchy:summary=Cycle to the next (or previous) bar style preset
# omarchy:args=[prev]
# omarchy:examples=omarchy bar style cycle | omarchy-bar-style-cycle prev
# omarchy:alias=omarchy barstyle cycle

set -euo pipefail

direction="${1:-next}"
case $direction in
  next | "") direction_arg="1" ;;
  prev | previous | back) direction_arg="-1" ;;
  *)
    echo "Usage: omarchy-bar-style-cycle [next|prev]" >&2
    exit 2
    ;;
esac

next=$(omarchy-shell shell cycleBarStyle "$direction_arg") || {
  echo "Could not reach the Omarchy shell IPC." >&2
  exit 1
}

if [[ $next == "cycle-failed" || -z $next ]]; then
  echo "Bar style cycle failed." >&2
  exit 1
fi

label=$(omarchy-shell -q shell listBarStyles 2>/dev/null | jq -r --arg id "$next" '.styles[] | select(.id == $id) | .label' 2>/dev/null || true)
omarchy-notification-send "Bar style: ${label:-$next}"
printf '%s\n' "$next"