@@ -74,10 +74,14 @@ def get_current_state_icon(self):
74
74
return self .get_resource (icon_name )
75
75
76
76
def get_current_mic_state (self ):
77
- ps = subprocess .Popen (("amixer" , "get" , "Capture" ), stdout = subprocess .PIPE )
78
- output = subprocess .check_output (('egrep' , '-o' , '\[o.+\]' , '-m' , '1' ), stdin = ps .stdout )
77
+ # ps = subprocess.Popen(("amixer", "get", "Capture"), stdout=subprocess.PIPE)
78
+ # output = subprocess.check_output(('egrep', '-o', '\[o.+\]', '-m', '1'), stdin=ps.stdout)
79
+ # ps.wait()
80
+ # #return filter(lambda x: not re.match(r'^\s*$', x), output)
81
+ # return output.decode().rstrip()
82
+ ps = subprocess .Popen ('pactl list sources | grep -A 10 $(pactl info | grep "Default Source" | cut -f3 -d" ")' , shell = True , stdout = subprocess .PIPE )
83
+ output = subprocess .check_output ('grep -qi "Mute: yes" && echo "[off]" || echo "[on]"' , shell = True , stdin = ps .stdout )
79
84
ps .wait ()
80
- #return filter(lambda x: not re.match(r'^\s*$', x), output)
81
85
return output .decode ().rstrip ()
82
86
83
87
def build_menu (self ):
@@ -124,7 +128,8 @@ def update_menu_toggle_label(self):
124
128
self .item_toggle .set_label ("Turn Microphone Off ( " + keystr + " )" )
125
129
126
130
def toggle_mic (self , _ ):
127
- subprocess .call ('amixer set Capture toggle' , shell = True )
131
+ # subprocess.call('amixer set Capture toggle', shell=True)
132
+ subprocess .call ('pactl set-source-mute @DEFAULT_SOURCE@ toggle' , shell = True )
128
133
self .update_mic_state ()
129
134
130
135
self .show_toggle_notification ()
0 commit comments