distribution/packages/sysutils/system-utils/sources/scripts/battery
fewtarius 1f6d96325b
* Fix ALSA on x86_64 handhelds.
* Temporary drop or correct multiple packages that needed updates for x86_64.
* Update volume service to deprecate hard coded paths.
* system-utils and sleep to common packages.
* Add weston kiosk.ini for future use.
* Add DIRTY variable, if true it will not clean.
2022-08-31 17:50:23 -04:00

57 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020-present Fewtarius
# Simple script to watch the battery capacity and
# turn the power LED red when it reaches 25%
. /etc/profile
function set_led() {
case $1 in
red)
echo out >/sys/class/gpio/gpio${DEVICE_LED}/direction
echo 1 >/sys/class/gpio/gpio${DEVICE_LED}/value
;;
green)
echo out >/sys/class/gpio/gpio${DEVICE_LED}/direction
echo 0 >/sys/class/gpio/gpio${DEVICE_LED}/value
;;
yellow)
echo in >/sys/class/gpio/gpio${DEVICE_LED}/direction
;;
esac
}
while true
do
CAP=$(cat /sys/class/power_supply/battery/capacity)
STAT=$(cat /sys/class/power_supply/battery/status)
if [ ${STAT} == "Discharging" ]
then
if (( ${CAP} <= 10 ))
then
for ctr in $(seq 1 1 5)
do
set_led yellow
sleep .5
set_led red
sleep .5
done
continue
elif (( ${CAP} <= 20 ))
then
set_led red
elif (( ${CAP} <= 30 ))
then
set_led yellow
else
set_led green
fi
elif (( ${CAP} >= 95 ))
then
set_led green
fi
sleep 15
done