bash/for_smol/bat.sh
cheesus_crust 9581bcc174 lets
2023-02-14 21:22:28 +03:00

24 lines
308 B
Bash
Executable File

#!/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