Add mute toggle button to volume thing

Signed-off-by: AKP <tom@tdpain.net>
This commit is contained in:
akp 2023-02-28 19:04:14 +00:00
parent bfbbee957e
commit 3218387be3
No known key found for this signature in database
GPG key ID: AA5726202C8879B7

View file

@ -179,10 +179,22 @@ func (g *PulseaudioVolume) applyVolumeDelta(percentageChange int) error {
return err
}
func (g *PulseaudioVolume) toggleMute() error {
// pactl set-sink-mute @DEFAULT_SINK@ toggle
sinkName := g.Sink
if sinkName == "" {
sinkName = "@DEFAULT_SINK@"
}
_, err := runCommand("pactl", "set-sink-mute", sinkName, "toggle")
return err
}
func (g *PulseaudioVolume) OnClick(event *i3bar.ClickEvent) bool {
var err error
switch event.Button {
case i3bar.LeftMouseButton:
err = g.toggleMute()
case i3bar.MouseWheelScrollUp:
err = g.applyVolumeDelta(1)
case i3bar.MouseWheelScrollDown: