bash/for_smol/bat.sh

24 lines
312 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 | sed 's#.*charging, ##;s#%.*##')
echo "$bat %"
if [[ "$bat" = 100 ]]
then
echo "Full"
exit 0
fi
if [[ "$bat" -lt 20 ]]
then
echo "Suspending"
systemctl suspend
exit 0
fi