From 4f45a4dd5320bd8b75fee81fbd0f0cdfb4b23101 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Tue, 14 Nov 2023 20:51:38 +0100 Subject: [PATCH] Update notify.sh --- {arch/stow/_scripts/.scripts => scripts}/notify.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) rename {arch/stow/_scripts/.scripts => scripts}/notify.sh (81%) diff --git a/arch/stow/_scripts/.scripts/notify.sh b/scripts/notify.sh similarity index 81% rename from arch/stow/_scripts/.scripts/notify.sh rename to scripts/notify.sh index faa63de..a9453d5 100755 --- a/arch/stow/_scripts/.scripts/notify.sh +++ b/scripts/notify.sh @@ -2,8 +2,10 @@ # Show system status in notification, or your own message # Syntaxis: notify [-vb] [-t ] [-p ] [ <message>] -# Requirements: +# Requirements/dependencies: +# - amixer # - brightnessctl +# - libnotify (notify-send) panic () { >&2 echo "Syntaxis: notify [-vb] [-t <timeout>] [-p <value>] [<title> <message>]" @@ -20,15 +22,15 @@ while getopts ":bvt:p:" options; do ;; v) # Get volume (don't use pamixer because that is way slower) - value=$( pactl get-sink-volume @DEFAULT_SINK@ \ - | cut -d '/' -f2 \ - | grep -o '[0-9]*%' \ - | tr -d '%' ) + value=$( amixer sget 'Master' \ + | grep -o '\[[0-9]*%\]' \ + | tr -d '][%' \ + | head -n1 ) title="Volume: ${value}%" category='sysinfo' # If audio disabled, set value to zero. - if [ "$( pactl get-sink-mute @DEFAULT_SINK@ )" == "Mute: yes" ] ; then + if [ "$( amixer sget 'Master' | grep -o '\[\(on\|off\)\]' | head -n1 )" == "[off]" ] ; then title="Volume: ${value}% (Disabled)" value=0 fi