You are not logged in.

#1 2020-09-03 18:46:21

leminhman0312
Member
Registered: 2020-07-12
Posts: 7

Dunstify script Arch wiki unable to unmute

I used the dunstify script from the Arch wiki:

https://wiki.archlinux.org/index.php/Du … _indicator


#!/bin/bash
# changeVolume

# Arbitrary but unique message id
msgId="991049"

# Change the volume using alsa(might differ if you use pulseaudio)
amixer -c 0 set Master "$@" > /dev/null

# Query amixer for the current volume and whether or not the speaker is muted
volume="$(amixer -c 0 get Master | tail -1 | awk '{print $4}' | sed 's/[^0-9]*//g')"
mute="$(amixer -c 0 get Master | tail -1 | awk '{print $6}' | sed 's/[^a-z]*//g')"
if [[ $volume == 0 || "$mute" == "off" ]]; then
    # Show the sound muted notification
    dunstify -a "changeVolume" -u low -i audio-volume-muted -r "$msgId" "Volume muted" 
else
    # Show the volume notification
    dunstify -a "changeVolume" -u low -i audio-volume-high -r "$msgId" \
    "Volume: ${volume}%" "$(getProgressString 10 "<b> </b>" " " $volume)"
fi

# Play the volume changed sound
canberra-gtk-play -i audio-volume-change -d "changeVolume"

where getProgressString is another script, reference by the Arch wiki to:

https://github.com/Fabian-G/dotfiles/bl … ressString

Problem
Volume up, down, mute works fine.  But I cannot unmute the volume. Pressing unmute would show a notification of volume being unmuted, but the actual volume is still muted.  I have to manually click on the volume icon in i3bar to unmute it. 

Setup to reproduce problem

  • Vanilla Arch on i3wm.

  • Dunst installed.

  • volumeicon installed

Attempt
I tried to add a third elif case to unmute the volume, but I am not sure if I get the syntax right, i.e. audio-volume-unmuted does not seem to get the job done.

if [[ $volume == 0 || "$mute" == "off" ]]; then
    # Show the sound muted notification
    dunstify -a "changeVolume" -u low -i audio-volume-muted -r "$msgId" "Volume muted"

elif [["$mute" == "on"]]; then 
    
    dunstify -a "changeVolume" -u low -i audio-volume-unmuted -r "$msgId" "Volume unmuted"
 
else
    # Show the volume notification
    dunstify -a "changeVolume" -u low -i audio-volume-high -r "$msgId" \
		"Volume: ${volume}%" "$(getProgressString 10 "<b> </b>" " " $volume)"
fi

Any suggestions are greatly appreciated.

Offline

#2 2020-09-03 19:54:13

seth
Member
Registered: 2012-09-03
Posts: 16,607

Re: Dunstify script Arch wiki unable to unmute

dunstify does not change the volume at all (it just talks to dunst for the notification), apparently the script takes an integer and uses it to set the master handling, but does not toggle mute anywhere - this has to come from somewhere else (eg. by use setting it to 0?)
If your card supports the mute feature you should use that, otherwise you'll have to re/store the value and toggle that w/ 0.

Offline

Board footer

Powered by FluxBB