/ de-omarchy / bin / omarchy-bar-style-menu
swadhinbiswas Add bar style presets: 10 themes, live set/cycle over shell IPC, omarchy bar style CLI · 8/24/2026
fe09911
47 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
#!/bin/bash

# omarchy:summary=Pick a bar style preset from the menu
# omarchy:examples=omarchy bar style menu
# omarchy:alias=omarchy barstyle menu

set -euo pipefail

# FontAwesome-range glyphs — present in every Nerd Font build.
declare -A STYLE_ICONS=(
  [classic]=$'\uf0c9'
  [floating-islands]=$'\uf00a'
  [glass]=$'\uf06e'
  [capsule]=$'\uf111'
  [terminal-boxed]=$'\uf120'
  [minimal-line]=$'\uf068'
  [gradient-wave]=$'\uf1fe'
  [oled-black]=$'\uf186'
  [soft-rounded]=$'\uf118'
  [segmented]=$'\uf0db'
)

styles_json=$(omarchy-shell -q shell listBarStyles 2>/dev/null || true)
if [[ -z $styles_json ]] || ! jq -e '.styles | length > 0' <<<"$styles_json" >/dev/null 2>&1; then
  echo "Omarchy shell not reachable — cannot list bar styles." >&2
  exit 1
fi

# The id rides along as row subtext and comes back with the selection, same
# trick omarchy-menu-plugin uses to tell rows apart.
rows=""
while IFS=$'\t' read -r id label; do
  icon=${STYLE_ICONS[$id]:-$'\uf29c'}
  mark=""
  active=$(jq -r '.active' <<<"$styles_json")
  [[ $id == "$active" ]] && mark="* "
  rows+="${icon}"$'\t'"${mark}${label}"$'\t'"${id}"$'\n'
done < <(jq -r '.styles[] | [.id, .label] | @tsv' <<<"$styles_json")

selection=$(omarchy-menu-select "Bar style" <<<"$rows") || exit 0
[[ -n $selection ]] || exit 0

style_id=$(cut -f3 <<<"$selection")
[[ -n $style_id ]] || exit 1

exec omarchy-bar-style-set "$style_id"