/ de-omarchy / bin / omarchy-audio-sink-availability
swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
55 lines · 1.0 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
51
52
53
54
55
#!/bin/bash

# omarchy:summary=Print PulseAudio sink availability for the shell
# omarchy:group=audio

# A speaker tuning is a virtual sink in front of the real speakers. Both exist
# in the graph, but selecting the physical one would only bypass the tuning, so
# report it unavailable and keep it out of the output list.
fronted="$(omarchy-audio-tuning fronted-sink 2>/dev/null || true)"

pactl list sinks 2>/dev/null | awk -v fronted="$fronted" '
  function emit_sink() {
    if (name == "") return
    if (fronted != "" && name == fronted) {
      print name "\t0"
      return
    }
    print name "\t" ((port_count == 0 || available) ? 1 : 0)
  }

  /^Sink #/ {
    emit_sink()
    name = ""
    in_ports = 0
    port_count = 0
    available = 0
    next
  }

  /^[[:space:]]*Name:/ {
    name = $2
    next
  }

  /^[[:space:]]*Ports:$/ {
    in_ports = 1
    next
  }

  in_ports && /^\tActive Port:/ {
    in_ports = 0
    next
  }

  in_ports && /^\t\t/ {
    port_count++
    if ($0 !~ /not available/) available = 1
    next
  }

  END {
    emit_sink()
  }
'