pmaports/device/testing/device-nokia-n900/i3wm/scripts/battery-bq27200
Oliver Smith 64035ac463
device/*: move to device/testing/* (!1063)
Prepare for better device categorization by moving everything to testing
subdir first.

[skip-ci]: chicken-egg problem: passing pmaports CI depends on pmbootstrap MR
				depends on this MR

Related: postmarketos#16
2020-03-14 08:35:32 +01:00

37 lines
1 KiB
Bash

#!/bin/sh
# i3status wrapper for displaying correct battery status on N900/bq27200
#
# Author:
# - Sicelo A. Mhlongo <absicsz@gmail.com> (2018)
# - Martijn Braam <martijn@brixit.nl> (2019, updated for i3blocks)
# Based on i3status/contrib/net-speed.sh by
#
# - Moritz Warning <moritzwarning@web.de> (2016)
# - Zhong Jianxin <azuwis@gmail.com> (2014)
#
# See file LICENSE in the i3status root directory for license information.
#
battery_path="/sys/class/power_supply/bq27200-0/"
read capacity < "${battery_path}capacity"
read chg_full < "${battery_path}charge_full"
read voltage < "${battery_path}voltage_now"
read disch_rate < "${battery_path}current_now"
if [[ "x$capacity" == "x" ]]; then
notification="$(( ( chg_full / 1000 ) ))mAh -- $(( ( voltage / 1000 ) ))mV @ $(( ( disch_rate / -1000 ) ))mA"
else
notification="$capacity%\/$(( ( chg_full / 1000 ) ))mAh -- $(( ( voltage / 1000 ) ))mV @ $(( ( disch_rate / -1000 ) ))mA"
fi
echo $notification
echo $notification
if [[ $disch_rate -gt 1 ]]; then
echo "#FFFFFF"
else
echo "#0099FF"
fi