From a20f58ce0017072a54cd2cd8b818179e833f8e42 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Mon, 6 Feb 2023 22:51:45 +0100 Subject: [PATCH] add pamixer notification wrapper --- .local/bin/pamixer-notify | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 .local/bin/pamixer-notify diff --git a/.local/bin/pamixer-notify b/.local/bin/pamixer-notify new file mode 100755 index 00000000..39bba661 --- /dev/null +++ b/.local/bin/pamixer-notify @@ -0,0 +1,35 @@ +#!/bin/sh + +# Arbitrary but unique message tag +msgTag="volume" + +# Change the volume using alsa(might differ if you use pulseaudio) +pamixer "$@" > /dev/null + +# Query amixer for the current volume and whether or not the speaker is muted +volume="$(pamixer --get-volume)" + +if [ "$volume" -gt "100" ]; then + urgency="critical" +else + urgency="low" +fi + +if [ "$volume" -gt "70" ]; then + icon="audio-volume-high" +elif [ "$volume" -gt "30" ]; then + icon="audio-volume-medium" +elif [ "$volume" -gt "0" ]; then + icon="audio-volume-low" +fi + +mute="$(pamixer --get-mute)" +if [ "$volume" = 0 ] || [ "$mute" = "true" ]; then + notify-send -a "changeVolume" -i "audio-volume-muted" -u $urgency -h string:x-dunst-stack-tag:$msgTag "Volume muted" +else + notify-send -a "changeVolume" -i "$icon" -u $urgency -h string:x-dunst-stack-tag:$msgTag \ + -h int:value:"$volume" "Volume: ${volume}%" +fi + +# Play the volume changed sound +canberra-gtk-play -i audio-volume-change -d "changeVolume"