Skip to content

Commit 8798346

Browse files
authored
pipewire-microphone: replace pw-cat
1 parent d902586 commit 8798346

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

polybar-scripts/pipewire-microphone/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ A script for showing and toggling the mute state of the PipeWire default microph
66
## Dependencies
77

88
* pactl (libpulse)
9-
* pw-cat (pipewire)
109

1110

1211
## Module

polybar-scripts/pipewire-microphone/pipewire-microphone.sh

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
11
#!/bin/sh
22

33
get_mic_default() {
4-
pw-cat --record --list-targets | sed -n -E "1 s/^.*: (.*)/\1/p"
4+
pactl info | awk '/Default Source:/ {print $3}'
55
}
66

77
is_mic_muted() {
8-
mic_name="$(get_mic_default)"
9-
10-
pactl list sources | \
11-
awk -v mic_name="${mic_name}" '{
12-
if ($0 ~ "Name: " mic_name) {
13-
matched_mic_name = 1;
14-
} else if (matched_mic_name && /Mute/) {
15-
print $2;
16-
exit;
17-
}
18-
}'
8+
pactl get-source-mute "$(get_mic_default)" | awk '{print $2}'
199
}
2010

2111
get_mic_status() {
22-
is_muted="$(is_mic_muted)"
23-
24-
if [ "${is_muted}" = "yes" ]; then
12+
if [ "$(is_mic_muted)" = "yes" ]; then
2513
printf "%s\n" "#1"
2614
else
2715
printf "%s\n" "#2"
@@ -30,9 +18,8 @@ get_mic_status() {
3018

3119
listen() {
3220
get_mic_status
33-
3421
LANG=EN; pactl subscribe | while read -r event; do
35-
if printf "%s\n" "${event}" | grep --quiet "source" || printf "%s\n" "${event}" | grep --quiet "server"; then
22+
if printf "%s\n" "${event}" | grep -qE '(source|server)'; then
3623
get_mic_status
3724
fi
3825
done
@@ -42,7 +29,7 @@ toggle() {
4229
pactl set-source-mute @DEFAULT_SOURCE@ toggle
4330
}
4431

45-
case "$1" in
32+
case "${1}" in
4633
--toggle)
4734
toggle
4835
;;

0 commit comments

Comments
 (0)