setup-cockpit/dotfiles/i3/scripts/battery
2022-02-15 14:42:43 +01:00

16 lines
538 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 "$TIME" ]; then
notify-send "CHARGE BATTERY"
for file in /dev/pts/*; do
if [ "$(ls -l "$file" | awk '{print $5}')" = '136,' ]; then
echo "CHARGE BATTERY" >> "$file"
fi
done
fi
echo "${icon} ${percent} (${remaining})"