Last active
October 7, 2017 06:16
-
-
Save ffflorian/0a52bc7edde6da69b2f6 to your computer and use it in GitHub Desktop.
Linux Mint Cinnamon: Display a notification when battery is running low
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original from http://unix.stackexchange.com/questions/60778/how-can-i-get-an-alert-when-my-battery-is-about-to-die-in-linux-mint | |
# Added a second notification | |
#!/bin/bash | |
POWERSUPPLY="/sys/class/power_supply/AC/online" | |
STATUS_LOW=25 | |
STATUS_CRITICAL=10 | |
NOT_CHARGING="0" | |
ICON_LOW="/usr/share/icons/Mint-X/status/scalable/battery-low-symbolic.svg" | |
ICON_CRITICAL="/usr/share/icons/Mint-X/status/scalable/battery-empty-symbolic.svg" | |
export DISPLAY=:0 | |
BATTERY_LEVEL=$(acpi -b | grep -P -o '[0-9]+(?=%)') | |
STATUS=$(cat $POWERSUPPLY) | |
if [ $BATTERY_LEVEL -le $STATUS_CRITICAL -a $STATUS = $NOT_CHARGING ] | |
then | |
notify-send -u critical -i "$ICON_CRITICAL" -t 3000 "Battery level is at ${BATTERY_LEVEL} %!" | |
elif [ $BATTERY_LEVEL -le $STATUS_LOW -a $STATUS = $NOT_CHARGING ] | |
then | |
notify-send -u normal -i "$ICON_LOW" -t 3000 "Battery level is at ${BATTERY_LEVEL} %!" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment