blob: 24410395d1439142fc7cf7c02882f0628f7a01a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/bin/sh
# Emit waybar JSON when any /dev/video* device is held open by a process.
# V4L2 capture (firefox, zoom, OBS, etc.) doesn't go through PipeWire's
# privacy portal, so the built-in waybar privacy module never sees it.
set -eu
devs=$(echo /dev/video[0-9]*)
case "$devs" in
'/dev/video[0-9]*') exit 0 ;; # no devices present
esac
# fuser exits 0 when at least one device has an opener, 1 otherwise. Stderr
# carries 'PID' for each match; redirect it away.
# shellcheck disable=SC2086 # $devs is an intentional space-separated list of paths
if fuser $devs >/dev/null 2>&1; then
printf '{"text":"","tooltip":"webcam in use","class":"active","alt":"active"}\n'
else
printf '{"text":"","alt":"idle"}\n'
fi
|