24 lines
308 B
Bash
24 lines
308 B
Bash
|
#!/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
|