Closed Yasuhan closed 7 months ago
There are 2 solutions I'm thinking of:
ooh, there's a list on arch wiki for what we're looking for: https://wiki.archlinux.org/title/PulseAudio#Graphical so far
The previous rice I used had waybar and used something akin to this:
# Toggle Mic toggle_mic() { if [ "$(pamixer --default-source --get-mute)" == "false" ]; then pamixer --default-source -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF" elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then pamixer -u --default-source u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone.png" "Microphone Switched ON" fi }
Not sure how you'd best implement that into AGS though?
Edit: Less ugly, not sure how to properly format here:
to format wrap in a code block with 3 backticks, like this: ```bash # write code here # that "bash" there is the language name ```
anyway i'm going to implement the 1st solution real quick
now, what keybind should i use :thinking:
I'd probably put it on Super+XF86AudioMute?
sure
done test it please?
The keybind works, I just don't get the icon.
Yeah..that doesn't happen for me. :sweat_smile:
did you update the ags config? is there anything in the logs? can you open a terminal, run pkill ags; ags
and show the output when you press the toggle keybind?
https://github.com/end-4/dots-hyprland/assets/30007466/0fadc94c-b0a8-4911-a6dc-8424767c2ee5
Config updated, since the bluetooth toggles you added earlier also just appeared.
just commited 7a9f25aa99e72d642ed6cd387aefb85eee723090 which i think should fix the logs try again
It fixed the logs, but now I only have the bar on my main monitor and the icon still isn't loading.
I fixed it by changing
Audio.microphone.isMuted
to
Audio.microphone.stream.is_muted
as that seems to be the proper way to do it? https://github.com/Aylur/ags/issues/123
Only have the issue that I now get this:
(com.github.Aylur.ags:33404): Gjs-CRITICAL **: 17:56:33.465: JS ERROR: TypeError: (intermediate value).microphone.stream is null
The toggle works fine though..so no clue what's up there.
Yea that's the proper way to do it. And from what I last remember from reading the ags docs maybe months ago (that was January), both the isMuted
and stream
are async and their values initially are null. So optional object chaining is preferred instead, like so:
- Audio.microphone.stream.isMuted
+ Audio.microphone?.stream?.isMuted
That intermediate value is null
something error/warning is initially displayed at first since value is still null so it errors out, until it's been properly set up and its value is no longer null. That's maybe why it eventually works just fine as you said.
Shrug, just async things I guess?
Ah, perfect. Changing that now completely fixed it and no more errors appear. Thanks!
Edit: Changed the whole thing in my own fork now to be always visible, too - in case someone else wants it?
export const MicMuteIndicator = () => Widget.Stack({
transition: 'slide_up_down',
transitionDuration: userOptions.animations.durationSmall,
children: {
'off': Widget.Label({ className: 'txt-norm icon-material', label: 'mic_off' }),
'on': Widget.Label({ className: 'txt-norm icon-material', label: 'mic' }),
},
setup: (self) => self.hook(Audio, stack => {
if (Audio.microphone?.stream?.is_muted)
stack.shown = 'off';
else
stack.shown = 'on';
}),
});
i guess that'll do
What would you like to be added? I'd like to have a button in the top bar (maybe next to the ethernet/bluetooth icons), that on-click mutes/unmutes the microphone.
How will it help I use this rice on my work rig as well, and sometimes I need to quickly mute/unmute myself in meetings or Mumble even when the window is hidden/covered by something else. A mute button for the mic that's accessible from all my screens with just one simple click would be the perfect solution to that for me, and I would also see at a glance if my mic is on/off. It also helps, that it would be a global mute, with so many different things I sometime lose track what I'm actually talking on right now.
Extra info Something likes this, to see it at a glance is super helpful for work setups.