File tree Expand file tree Collapse file tree 2 files changed +5
-19
lines changed
polybar-scripts/pipewire-microphone Expand file tree Collapse file tree 2 files changed +5
-19
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ A script for showing and toggling the mute state of the PipeWire default microph
6
6
## Dependencies
7
7
8
8
* pactl (libpulse)
9
- * pw-cat (pipewire)
10
9
11
10
12
11
## Module
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
3
get_mic_default () {
4
- pw-cat --record --list-targets | sed -n -E " 1 s/^.*: (.*)/\1/p "
4
+ pactl info | awk ' /Default Source:/ {print $3} '
5
5
}
6
6
7
7
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}'
19
9
}
20
10
21
11
get_mic_status () {
22
- is_muted=" $( is_mic_muted) "
23
-
24
- if [ " ${is_muted} " = " yes" ]; then
12
+ if [ " $( is_mic_muted) " = " yes" ]; then
25
13
printf " %s\n" " #1"
26
14
else
27
15
printf " %s\n" " #2"
@@ -30,9 +18,8 @@ get_mic_status() {
30
18
31
19
listen () {
32
20
get_mic_status
33
-
34
21
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
36
23
get_mic_status
37
24
fi
38
25
done
@@ -42,7 +29,7 @@ toggle() {
42
29
pactl set-source-mute @DEFAULT_SOURCE@ toggle
43
30
}
44
31
45
- case " $1 " in
32
+ case " ${1} " in
46
33
--toggle)
47
34
toggle
48
35
;;
You can’t perform that action at this time.
0 commit comments