Fixed muted audio

This commit is contained in:
Tibo De Peuter 2022-06-01 21:38:20 +02:00
parent 9879d5f01e
commit 78b3e07fb9

View file

@ -1,26 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Show system status in notification, or your own message # Show system status in notification, or your own message
# Syntaxis: notify [-vb] <message> # Syntaxis: notify [-vb] [<title> <message>]
# Variables
value=0
# Get options # Get options
while getopts ":bvm:" options; do while getopts ":bv" options; do
case "${options}" in case "${options}" in
b) b)
value=$(brightnessctl | grep -o "[0-9]*%") value=$(brightnessctl | grep -o "[0-9]*%")
title="Brightness: ${value}" title="Brightness: ${value}"
timeout=2000
;; ;;
v) v)
value=$(pactl get-sink-volume @DEFAULT_SINK@ | cut -d '/' -f2 | grep -o '[0-9]*%') value=$(pactl get-sink-volume @DEFAULT_SINK@ | cut -d '/' -f2 | grep -o '[0-9]*%')
# if [[ $status == "[on]" ]] ; then status=$(amixer get Master | grep "^ Front Left" | cut -d ' ' -f 8)
# value=$(amixer get Master | grep -o "[0-9]*%" | head -n 1) if [[ $status != "[on]" ]] ; then
# fi value="Disabled"
fi
title="Volume: ${value:-'0%'}" title="Volume: ${value:-'0%'}"
;; timeout=2000
m)
message=${OPTARG}
;; ;;
*) *)
title="Unknown option" title="Unknown option"
@ -30,9 +27,26 @@ done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
notify-send "${title:-${message}}" "${message}" \ # Check arguments
-t 2000 \ if [[ $# -gt 2 ]] ; then
>&2 echo "Syntaxis: notify [-vb] [<title> [<message>]]"
exit 1
elif [[ $# -eq 2 ]] ; then
title=$1
message=$2
elif [[ $# -eq 1 ]] ; then
title=$1
fi
# Calculate length of coloured bar.
if [[ "${value}" =~ ^[0-9]+%$ ]] ; then
width=$(grep -o "[0-9]*" <<< "${value}")
fi
# Send message
notify-send "${title}" "${message}" \
-t "${timeout:=5000}" \
-c byMe \ -c byMe \
-h int:value:"$(grep -o "[0-9]*" <<< "${value}")" \ -h int:value:"${width:=0}" \
-h string:x-canonical-private-synchronous:byMe # Replace if not yet gone -h string:x-canonical-private-synchronous:byMe # Replace if not yet gone