From 01abbff07781d55101f5a347634de49631709579 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Fri, 6 Sep 2024 10:34:05 +0800 Subject: more hyprland scripts --- hyprindicator | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 hyprindicator (limited to 'hyprindicator') diff --git a/hyprindicator b/hyprindicator new file mode 100755 index 0000000..46f4753 --- /dev/null +++ b/hyprindicator @@ -0,0 +1,44 @@ +#!/bin/bash + +function Mic { + # inotifywait -e modify /proc/asound/card0/pcm0c/sub0/status # doesnt work :( + rawMicStatus=$(cat /proc/asound/card0/pcm0c/sub0/status) + if [[ $rawMicStatus == *"closed"* ]]; then + # echo "Mic is closed" + unset micpid + return 1 + else + micpid=$(printf "%s" "$rawMicStatus" | grep 'owner_pid' | awk -F ': ' '{print $2}') + fi +} + +function Camera { + campid=$(fuser "/dev/video0" 2>/dev/null) || unset campid + # icampid=$(fuser "/dev/video2" 2>/dev/null) # IR camera + if [ $campid ]; then + unset campid + else + return 1 + fi +} + +function subscribe { + while true; do + Mic + Camera + if [ ! $micpid ] && [ ! $campid ]; then + echo '{"text": " ", "tooltip": " ", "class": "no"}' + elif [ $micpid ] && [ ! $campid ]; then + echo '{"text": "", "tooltip": "Mic: '$micpid'", "class": "mic"}' + elif [ ! $micpid ] && [ $campid ]; then + echo '{"text": "", "tooltip": "Camera: '$campid'", "class": "cam"}' + else + echo '{"text": " ", "tooltip": "Mic: '$micpid' Camera: '$campid'", "class": "miccam}' + fi + sleep 1 + done +} + +if [ "$1" ]; then + $@ +fi -- cgit v1.2.3