Batify is a Bash script to set easily plug and battery level notifications using udev rules and libnotify for single and multi-xusers.
In order to use libnotify, you need to install a notification server.
$ yaourt -S batify
$ git clone https://github.com/Ventto/batify.git
$ cd batify
$ make
$ sudo make install
After installing batify, do not forget to reload udev rules:
$ udevadm control --reload-rules
"A batifyrc configuration file is comming soon"
Current notifications:
notification | level |
---|---|
Battery level is between 10% and 15% | normal |
Battery level is less than 9% | critical |
AC adapter plugged-in | normal |
AC adapter unplugged | normal |
Batify's files:
/etc/udev/rules.d/99-batify.rules
/usr/local/bin/batify.sh
/usr/share/icons/batify/*.png
- Edit
batify.sh
:
case ${_bat_capacity} in
[0-9]) ntf_lvl=critical; icon="bat-critical" ;;
1[0-5]) ntf_lvl=low; icon="bat-low" ;;
# Custom warnings (battery half level)
5[0-3]) ntf_lvl=normal; icon="bat-half" ;;
50) ... ;;
*) exit ;;
esac
- Edit
batify.sh
:
if [ "${_bat_plug}" == "1" ]; then
ntf_lvl="normal"; icon="bat-plug"
ntf_msg="Power: plugged in"
else
ntf_lvl="normal" ; icon="bat-unplug"
ntf_msg="Power: unplugged"
fi
- Edit
batify.sh
:
ICON_DIR="/usr/share/icons/batify"
#[...]
icon_path="${ICON_DIR}/${icon}.png"