Waybar
Waybar copied to clipboard
privacy: Add camera and location indicator
Add an indicator for camera and location usage. When an application is accessing the camera/webcam or location it will show an indicator.
For the camera , I believe it's pipewire related, if not then monitoring /dev/video* might be a solution if there was no other API.
From #2612:
This can be extended in the future to show Geoclue status (location usage), XWayland screen share status, and camera status :)
Tasks:
- [ ] Add camera indicator.
- [ ] Add location indicator.
I made a config for the webcam!
Home Manager nix config:
"custom/webcam" = {
return-type = "json";
interval = 2;
exec = mkScript {
deps = [pkgs.jq pkgs.psmisc];
script = ''
# get programs using the video0 endpoint
ps -eo user,pid,cmd -q "$(fuser /dev/video0 2>/dev/null | xargs)" |\
# omit the column headings and the first line which is wireplumber
sed -n "1,2!p" |\
# just get the pid and program columns
awk '{print $2 " " $3}' |\
# filter out the program path
awk -F "/" '{print "{\"tooltip\": \"" $1 " " $NF "\"}"}' |\
jq -s 'if length > 0 then {text: " ", tooltip: (map(.tooltip) | join("\r"))} else {text: " ", tooltip: "No applications are using your webcam!"} end' |\
jq --unbuffered --compact-output
'';
};
};
normal waybar config:
"custom/webcam": {
"exec": 'path/to/script',
"interval": 2,
"return-type": "json"
}
You need to have the fuser and jq commands available
# get programs using the video0 endpoint
ps -eo user,pid,cmd -q "$(fuser /dev/video0 2>/dev/null | xargs)" |\
# omit the column headings and the first line which is wireplumber
sed -n "1,2!p" |\
# just get the pid and program columns
awk '{print $2 " " $3}' |\
# filter out the program path
awk -F "/" '{print "{\"tooltip\": \"" $1 " " $NF "\"}"}' |\
jq -s 'if length > 0 then {text: " ", tooltip: (map(.tooltip) | join("\r"))} else {text: " ", tooltip: "No applications are using your webcam!"} end' |\
jq --unbuffered --compact-output
my version of this:
fuser /dev/video* 2>/dev/null|xargs -r ps --no-headers -eo pid,comm -q \
| sed 's/\.\(.*\)-wra\?p\?p\?e\?d\?/\1/g' \
| awk '{print "{\"tooltip\": \"" $NF " " "["$1"]" "\"}"}' \
| jq -s 'if length > 0 then {text: "", tooltip: (map(.tooltip) | join("\r"))} else {text: "", tooltip: "No spying eyes!"} end' \
| jq --unbuffered --compact-output
Also of note mkScript is parents addition,and can be found here