Skip to content

Commit e30a700

Browse files
committed
fix: mute toggle issues
1 parent 6f16a53 commit e30a700

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

micindicator.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ def get_current_state_icon(self):
7474
return self.get_resource(icon_name)
7575

7676
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)
7984
ps.wait()
80-
#return filter(lambda x: not re.match(r'^\s*$', x), output)
8185
return output.decode().rstrip()
8286

8387
def build_menu(self):
@@ -124,7 +128,8 @@ def update_menu_toggle_label(self):
124128
self.item_toggle.set_label("Turn Microphone Off ( " + keystr + " )")
125129

126130
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)
128133
self.update_mic_state()
129134

130135
self.show_toggle_notification()

0 commit comments

Comments
 (0)