diff options
| author | 2026-05-13 13:43:28 +0100 | |
|---|---|---|
| committer | 2026-05-13 13:43:28 +0100 | |
| commit | 4c5021e8af8f8b93c517949900e14f1d421d3f8e (patch) | |
| tree | ba39719a1d7c61437cc65a28e90d14bdc198a273 | |
| parent | 0fff052767335f33018c0896390e528aa6ec3dd3 (diff) | |
| download | dotfiles-4c5021e8af8f8b93c517949900e14f1d421d3f8e.tar.gz dotfiles-4c5021e8af8f8b93c517949900e14f1d421d3f8e.tar.bz2 dotfiles-4c5021e8af8f8b93c517949900e14f1d421d3f8e.zip | |
feat(waybar): add webcam privacy indicator
V4L2 capture goes directly through /dev/videoN and never traverses
the PipeWire portal, so the built-in privacy module misses it. New
custom/webcam module polls fuser on /dev/video* every 2s and shows
a red 'CAM' badge when any device is held open.
Empty text when idle, so the slot collapses and stays out of the way
when the webcam is unused (i.e. always, on a usual day).
| -rw-r--r-- | dot_config/waybar/config.jsonc | 8 | ||||
| -rw-r--r-- | dot_config/waybar/executable_webcam-status.sh | 18 | ||||
| -rw-r--r-- | dot_config/waybar/style.css | 5 |
3 files changed, 31 insertions, 0 deletions
diff --git a/dot_config/waybar/config.jsonc b/dot_config/waybar/config.jsonc index 47d6b64..c09eb1f 100644 --- a/dot_config/waybar/config.jsonc +++ b/dot_config/waybar/config.jsonc @@ -12,6 +12,7 @@ "network#bond", "battery", "privacy", + "custom/webcam", "pulseaudio", "custom/wifi", "bluetooth", @@ -169,6 +170,13 @@ ], }, + "custom/webcam": { + "exec": "~/.config/waybar/webcam-status.sh", + "return-type": "json", + "interval": 2, + "tooltip": true, + }, + "custom/notifications": { "exec": "~/.config/waybar/mako-status.sh", "return-type": "json", diff --git a/dot_config/waybar/executable_webcam-status.sh b/dot_config/waybar/executable_webcam-status.sh new file mode 100644 index 0000000..b8e5570 --- /dev/null +++ b/dot_config/waybar/executable_webcam-status.sh @@ -0,0 +1,18 @@ +#!/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. +if fuser $devs >/dev/null 2>&1; then + printf '{"text":"CAM","tooltip":"webcam in use","class":"active","alt":"active"}\n' +else + printf '{"text":"","alt":"idle"}\n' +fi diff --git a/dot_config/waybar/style.css b/dot_config/waybar/style.css index 3072ad2..29d9885 100644 --- a/dot_config/waybar/style.css +++ b/dot_config/waybar/style.css @@ -48,6 +48,7 @@ window#waybar { #privacy, #custom-memory, #custom-wifi, +#custom-webcam, #custom-notifications, #custom-thunderbird { padding: 0 6px; @@ -118,6 +119,10 @@ window#waybar { color: #fb4934; /* red — only visible when active */ } +#custom-webcam.active { + color: #fb4934; /* red — only rendered when webcam is in use */ +} + #custom-notifications { color: #928374; /* gray baseline */ } |
