sisyphus/.config/i3/scripts/notify.sh

40 lines
900 B
Bash
Raw Normal View History

2022-03-18 11:35:14 +01:00
#!/bin/bash
# Show system status in notification, or your own message
# Syntaxis: notify [-vb] <message>
# Variables
duration=3
2022-03-21 16:00:53 +01:00
value=0
2022-03-18 11:35:14 +01:00
# Get options
while getopts ":bvm:" options; do
case "${options}" in
b)
2022-03-21 16:00:53 +01:00
value=$(brightnessctl | grep -o "[0-9]*%")
title="Brightness: ${value}"
2022-03-18 11:35:14 +01:00
;;
v)
2022-03-21 16:00:53 +01:00
status=$(amixer get Master | grep "^ Front Left" | cut -d ' ' -f 8)
if [[ $status == "[on]" ]] ; then
value=$(amixer get Master | grep -o "[0-9]*%" | head -n 1)
fi
title="Volume: ${value:-'0%'}"
2022-03-18 11:35:14 +01:00
;;
m)
message=${OPTARG}
;;
*)
title="Unknown option"
;;
esac
done
shift $((OPTIND - 1))
notify-send "${title:-${message}}" "${message}" \
2022-03-21 16:00:53 +01:00
-h int:value:"$(grep -o "[0-9]*" <<< ${value})" \
2022-03-18 11:35:14 +01:00
-h string:x-canonical-private-synchronous:byMe # Replace if not yet gone
2022-03-21 16:00:53 +01:00
#-h geometry = "400x200-40-40" \
canberra-gtk-play -i audio-volume-change -d "changeVolume"