blob: 9d5b360bebc490aa8011b682ddec562ba0ae2517 (
plain)
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
|
#!/bin/sh
#
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# One line, "mic cam loc scr", each 0 or 1: what is capturing right now.
# The rules are waybar-theme-udt's privacy_dots.sh. Mic and screen need
# pw-dump because a capturing source is told from an idle one by its node
# state, which Quickshell's PwNode does not expose.
dump=$(pw-dump 2>/dev/null)
mic=$(printf '%s' "$dump" | jq '[.[]
| select(.type == "PipeWire:Interface:Node")
| select(.info.props["media.class"] == "Audio/Source"
or .info.props["media.class"] == "Audio/Source/Virtual")
| select(.info.state == "running")] | if length > 0 then 1 else 0 end' 2>/dev/null)
scr=$(printf '%s' "$dump" | jq '[.[]
| select((.info?.props?["media.name"]? // "") | test("^(xdph-streaming|gsr-default)"))]
| if length > 0 then 1 else 0 end' 2>/dev/null)
cam=0
for dev in /dev/video*; do
[ -e "$dev" ] && fuser "$dev" >/dev/null 2>&1 && { cam=1; break; }
done
loc=0
pgrep -x geoclue >/dev/null 2>&1 && loc=1
echo "${mic:-0} $cam $loc ${scr:-0}"
|