Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # File: /home/sergio/.dotfiles/bin/checkbattery.sh
- # Last Change: Mon, 26 Sep 2022 16:40:52
- #
- # https://www.2daygeek.com/linux-low-full-charging-discharging-battery-notification/
- # crontab example where you can use this script:
- # https://pastebin.com/Jn36y4sW
- # removed loop because I am using a cronjob
- battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
- if [ $battery_level -ge 95 ]; then
- notify-send "Battery Full" "Level: ${battery_level}%"
- #paplay /usr/share/sounds/freedesktop/stereo/complete.oga
- elif [ $battery_level -le 20 ]; then
- notify-send --urgency=CRITICAL "Battery Low" "Level: ${battery_level}%"
- paplay /usr/share/sounds/freedesktop/stereo/suspend-error.oga
- fi
Advertisement
Add Comment
Please, Sign In to add comment