Skip to content

Commit

Permalink
Add support for $IS_MUTED
Browse files Browse the repository at this point in the history
  • Loading branch information
marioortizmanero committed Nov 7, 2021
1 parent 751da61 commit 3ae1ba6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Options:
* $VOL_LEVEL
* $ICON_SINK
* $SINK_NICKNAME
* $IS_MUTED (yes/no)
Default: $VOL_ICON ${VOL_LEVEL}% $ICON_SINK $SINK_NICKNAME
--icons-volume <icon>[,<icon>...]
Icons for volume, from lower to higher.
Expand Down
11 changes: 6 additions & 5 deletions pulseaudio-control.bash
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ function getNicknameFromProp() {
}

# Saves the status of the sink passed by parameter into a variable named
# `isMuted`.
# `IS_MUTED`.
function getIsMuted() {
isMuted=$(pactl list sinks | grep -E "^Sink #$1\$" -A 15 | awk '/Mute: / {print $2}')
IS_MUTED=$(pactl list sinks | grep -E "^Sink #$1\$" -A 15 | awk '/Mute: / {print $2}')
}


Expand Down Expand Up @@ -172,7 +172,7 @@ function volMute() {
fi
if [ "$1" = "toggle" ]; then
getIsMuted "$curSink"
if [ "$isMuted" = "yes" ]; then
if [ "$IS_MUTED" = "yes" ]; then
pactl set-sink-mute "$curSink" "no"
else
pactl set-sink-mute "$curSink" "yes"
Expand Down Expand Up @@ -266,7 +266,7 @@ function showOSD() {
fi
getCurVol "$curSink"
getIsMuted "$curSink"
qdbus org.kde.kded /modules/kosd showVolume "$VOL_LEVEL" "$isMuted"
qdbus org.kde.kded /modules/kosd showVolume "$VOL_LEVEL" "$IS_MUTED"
}


Expand Down Expand Up @@ -322,7 +322,7 @@ function output() {
getNickname "$curSink"

# Showing the formatted message
if [ "$isMuted" = "yes" ]; then
if [ "$IS_MUTED" = "yes" ]; then
# shellcheck disable=SC2034
VOL_ICON=$ICON_MUTED
echo "${COLOR_MUTED}$(eval echo "$FORMAT")${END_COLOR}"
Expand Down Expand Up @@ -362,6 +362,7 @@ Options:
* \$VOL_LEVEL
* \$ICON_SINK
* \$SINK_NICKNAME
* \$IS_MUTED (yes/no)
Default: $FORMAT
--icons-volume <icon>[,<icon>...]
Icons for volume, from lower to higher.
Expand Down

0 comments on commit 3ae1ba6

Please sign in to comment.