diff --git a/ansible/roles/sway/files/waybar_sound_linux.bash b/ansible/roles/sway/files/waybar_sound_linux.bash index 08f3101..46313f7 100644 --- a/ansible/roles/sway/files/waybar_sound_linux.bash +++ b/ansible/roles/sway/files/waybar_sound_linux.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Read volume status in FreeBSD +# Read volume status in Linux set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -9,8 +9,12 @@ SLEEP_INTERVAL=${SLEEP_INTERVAL:-30} while true; do current_vol_decimal=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/Volume: //g') - current_vol_percent=$(bc -s <<<"$current_vol_decimal * 100") - current_vol_percent=${current_vol_percent%.*} # Remove decimal + if [[ "$current_vol_decimal" = *MUTED* ]]; then + current_vol_percent=0 + else + current_vol_percent=$(bc -s <<<"$current_vol_decimal * 100") + current_vol_percent=${current_vol_percent%.*} # Remove decimal + fi tooltip="$(wpctl status)" tooltip=${tooltip//$'\n'/\\n} tooltip=${tooltip//$'\t'/\\t}