Dunst add progress bar support and new colors

This commit is contained in:
Przemek Grondek 2023-08-09 23:26:05 +02:00
parent 997d091fc6
commit 186d3f5e17
3 changed files with 31 additions and 17 deletions

View File

@ -2,15 +2,22 @@
### Display ### ### Display ###
monitor = 0 monitor = 0
follow = keyboard follow = keyboard
geometry = "300x5-30+20" width = 400
height = 200
offset = 30
origin = top-right
indicate_hidden = yes indicate_hidden = yes
shrink = no shrink = no
transparency = 20 transparency = 10
notification_height = 0 notification_height = 0
separator_height = 2 separator_height = 2
padding = 8 padding = 8
horizontal_padding = 8 horizontal_padding = 8
frame_width = 3 frame_width = 0
# progress bar
progress_bar_max_width = 400
progress_bar_min_width = 400
# Defines color of the frame around the notification window. # Defines color of the frame around the notification window.
frame_color = "#808080" frame_color = "#808080"
@ -20,7 +27,7 @@
### Text ### ### Text ###
font = Monospace 8 font = FiraCode 12
line_height = 0 line_height = 0
markup = full markup = full
@ -34,7 +41,7 @@
# %n progress value if set without any extra characters # %n progress value if set without any extra characters
# %% Literal % # %% Literal %
# Markup is allowed # Markup is allowed
format = "<tt><b>%s</b>\n%b\n\n<i>%a</i></tt>" format = "%s\n\n%b\n"
alignment = left alignment = left
show_age_threshold = -1 show_age_threshold = -1
@ -115,12 +122,13 @@
[urgency_low] [urgency_low]
background = "#222222" background = "#222222"
foreground = "#888888" foreground = "#888888"
timeout = 0 highlight = "#153EBC"
timeout = 3000
[urgency_normal] [urgency_normal]
background = "#222222" background = "#222222"
foreground = "#ffffff" foreground = "#ffffff"
timeout = 0 timeout = 30000
[urgency_critical] [urgency_critical]
background = "#900000" background = "#900000"

View File

@ -1,6 +1,10 @@
#!/bin/sh #!/bin/sh
# https://www.reddit.com/r/suckless/comments/m6r71v/comment/gr7t2z1/?utm_source=reddit&utm_medium=web2x&context=3 # source of first version: https://www.reddit.com/r/suckless/comments/m6r71v/comment/gr7t2z1/?utm_source=reddit&utm_medium=web2x&context=3
# My changes:
# * fixed double notifications for critical level
# * added dunst stack tag
# * added dunst value for progress bar
# Control variable # Control variable
# Possible values: NONE, FULL, LOW, CRITICAL # Possible values: NONE, FULL, LOW, CRITICAL
@ -21,23 +25,21 @@ while true; do
# If battery full and not already warned about that # If battery full and not already warned about that
if [ "$last" != "FULL" ] && [ "$status" = "Full" ]; then if [ "$last" != "FULL" ] && [ "$status" = "Full" ]; then
notify-send "Battery full" notify-send -h string:x-dunst-stack-tag:battery_notif -h "int:value:$last" "Battery full"
last="FULL" last="FULL"
fi fi
# If low and discharging # If low and discharging
if [ "$last" != "LOW" ] && [ "$status" = "Discharging" ] && \ if [ "$last" != "LOW" ] && [ "$status" = "Discharging" ] && [ $capacity -le $low ] && [ $capacity -gt $critical ]; then
[ $capacity -le $low ]; then notify-send -h string:x-dunst-stack-tag:battery_notif -h "int:value:$last" "Battery low: $capacity%"
notify-send "Battery low: $capacity%"
last=LOW last=LOW
fi fi
# If critical and discharging # If critical and discharging
if [ "$status" = "Discharging" ] && [ $capacity -le $critical ]; then if [ "$status" = "Discharging" ] && [ $capacity -le $critical ]; then
notify-send -u critical "Battery very low: $capacity%" notify-send -h string:x-dunst-stack-tag:battery_notif -h "int:value:$last" -u critical "Battery very low: $capacity%"
last=CRITICAL last=CRITICAL
fi fi
fi fi
sleep 60 sleep 60
done done

View File

@ -3,12 +3,16 @@
DEVICE=pulse DEVICE=pulse
NAME=Master NAME=Master
URGENCY=low URGENCY=low
EXPIRE=1500 EXPIRE=5000
ALSA_CMD="amixer -D $DEVICE" ALSA_CMD="amixer -D $DEVICE"
NOTIFY_CMD="notify-send -u $URGENCY -t $EXPIRE 🔊 " NOTIFY_CMD="notify-send -u $URGENCY -t $EXPIRE VOLUME "
$ALSA_CMD sset $NAME "$1" $ALSA_CMD sset $NAME "$1"
LEVEL=$($ALSA_CMD sget $NAME | awk -F"[][]" '/Left:/ { print $2 }') LEVEL=$($ALSA_CMD sget $NAME | awk -F"[][]" '/Left:/ { print $2 }')
$NOTIFY_CMD $LEVEL notify-send -u $URGENCY \
-h "int:value:$LEVEL" \
-h string:x-dunst-stack-tag:volume_notif \
-t $EXPIRE \
"VOLUME: $LEVEL"