setup-cockpit/dotfiles/i3/scripts/battery

11 lines
373 B
Bash
Executable file

#!/bin/bash
icon=""
percent="$(upower -d | grep 'percentage' | awk '{print $2}' | head -n 1)"
remaining="$(upower -d | grep 'time to empty' | awk -F: '{print $2}' | awk '{print $1,$2}' | head -n 1)"
if [ -n "$remaining" ] && [ "$(echo "$percent" | awk -F% '{print $1}')" -lt 5 ]; then
notify-send "CHARGE YOUR BATTERY"
fi
echo "${icon} ${percent} (${remaining})"