bash/for_smol/bat.sh

24 lines
312 B
Bash
Raw Permalink 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 | sed 's#.*charging, ##;s#%.*##')
2023-02-14 18:22:28 +00:00
echo "$bat %"
if [[ "$bat" = 100 ]]
then
echo "Full"
exit 0
fi
if [[ "$bat" -lt 20 ]]
then
echo "Suspending"
systemctl suspend
exit 0
fi