BlogLinux Mint. Checking Battery StatusLinux Mint does not come with battery watcher. It is a bit annoying when your laptop shuts down, all because you have forgotter to plug it in. After a bit of research found out this small bash script which does exactly what I wanted. The script will watch the battery and will notify you once it goes under a specified percentage
#!/bin/bash DEBUG:notify-send " Listening for battery status " -t 8000 Set the alert tone for battery, or leave it as empty quotes..mp3 or .ogg audio filealarm="/your/path/battery_notification.ogg" Notify when below this percentagewarning_level=70 How often to check battery status, in minutescheck_interval=2
while true; do battery_level=$(acpi -b \ | cut -d, -f2 | cut --characters=2,3,4 \ | sed 's/%//g') charging=$(acpi -b | grep -c "Charging")
# When battery is low, and not already charging if [ $battery_level -lt $warning_level ] && [ $charging -eq 0 ] then play -q -v 0.40 "$alarm" & notify-send " Low battery: ${battery_level}% " \ " Plug into mains power " -t 8000 fi
sleep ${check_interval}m done
So how to install it on Linux Mint.
The next time you restart your Linux Mint, you will get a nice notification once the battery starts to dwindle, Loading blog_post_recommendations...
|