Re: Trying to get a custom runit service to notify me when battery is low (dunst)
Reply #5 –
Thank you for that, and yes I've tried it from within my .xinitrc file where it works... but only on startup when the battery is at or below 15%. When I've left it on with the battery hovering around 15% power, it fails to launch again once it drops from 16% to 15%, which is when I'd like dunst to notify me.
I believe this has to do with dunst relying on dbus (for some reason...), so I will be integrating both your and Artist's recommendations later on tonight and record my findings here. To be clear, my batnotify script now looks like so, and will be called from in my .xinitrc :
#!/bin/sh
echo 'export DBUS_SESSION_BUS_ADDRESS='$DBUS_SESSION_BUS_ADDRESS > /tmp/dsba;
chmod +x /tmp/dsba;
/tmp/dbsa;
while [ true ] ; do
PWRLVL=$(cat /sys/class/power_supply/BAT1/capacity)
if [ $PWRLVL -le 15 ] ; then
exec notify-send "Battery is at 15%!!";
break;
else
sleep 15s;
fi
done