Skip to content
Snippets Groups Projects
Commit 7e5c8f1b authored by nimrod's avatar nimrod
Browse files

- Added scripts to show the battery charge percent on the PocketCHIP.

parent bfb4a628
Branches
No related tags found
No related merge requests found
#!/bin/sh
set -eu
current="$(cat /usr/lib/pocketchip-batt/voltage)"
. "$HOME/.local/voltage"
echo $(( 100 * (current - min) / (max - min) ))
#!/bin/sh
set -eu
# To install, add the folowing lines to your crontab:
# PATH="~/Documents/bin:/usr/local/bin:/usr/bin:/bin"
# */5 * * * * update-voltage
filepath="$HOME/.local/voltage"
update_voltage () {
echo "min=$1" > "$filepath"
echo "max=$2" >> "$filepath"
}
current="$(cat /usr/lib/pocketchip-batt/voltage)"
mkdir -p "$(dirname "$filepath" )"
if [ ! -f "$filepath" ]
then
update_voltage "$current" "$current"
exit 0
fi
. "$filepath"
if [ "$current" -gt "$max" ]
then
max="$current"
update_voltage "$min" "$max"
elif [ "$current" -lt "$min" ]
then
min="$current"
update_voltage "$min" "$max"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment