/ de-omarchy / bin / omarchy-bar-style-set
swadhinbiswas Add bar style presets: 10 themes, live set/cycle over shell IPC, omarchy bar style CLI · 8/24/2026
fe09911
50 lines · 1.4 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

# omarchy:summary=Set the bar style preset by id
# omarchy:args=<style-id>
# omarchy:examples=omarchy bar style set glass | omarchy-bar-style-set floating-islands
# omarchy:alias=omarchy barstyle set

set -euo pipefail

if (( $# < 1 )) || [[ -z ${1:-} ]]; then
  echo "Usage: omarchy-bar-style-set <style-id>" >&2
  echo "Available styles:" >&2
  omarchy-bar-style-list | sed 's/^/  /' >&2
  exit 2
fi

style_id="$1"

known=$(omarchy-shell -q shell listBarStyles 2>/dev/null | jq -r --arg id "$style_id" '.styles[] | select(.id == $id) | .id' 2>/dev/null || true)

# Shell unreachable? Validate against the built-in order so the command still
# works from a TTY before the session is up.
if [[ -z $known ]]; then
  case $style_id in
    classic | floating-islands | glass | capsule | terminal-boxed | minimal-line | gradient-wave | oled-black | soft-rounded | segmented)
      known=$style_id
      ;;
  esac
fi

if [[ -z $known ]]; then
  echo "Unknown bar style: $style_id" >&2
  omarchy-bar-style-list | sed 's/^/  /' >&2
  exit 1
fi

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

if [[ $result != "ok" ]]; then
  echo "$result" >&2
  exit 1
fi

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