bash/for_smol/bat.sh

24 lines
308 B
Bash
Raw Normal View History

2023-02-14 18:22:28 +00:00
#!/bin/bash
state=$(acpi -a)
# echo "$state"
if [[ "$state" = "Adapter 0: on-line" ]]
then
echo "Charging"
exit 0
fi
bat=$(acpi -b | cut -b 25-27 | sed 's/%//')
echo "$bat %"
if [[ "$bat" = 100 ]]
then
echo "Full"
exit 0
fi
if [[ "$bat" -lt 20 ]]
then
echo "Suspending"
systemctl suspend
exit 0
fi