device-nokia-n900: i3wm: use upower for battery status (MR 4397)

This commit is contained in:
Sicelo A. Mhlongo 2023-09-11 15:45:36 +02:00 committed by Oliver Smith
parent 170189393b
commit e12d937c6b
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 13 additions and 36 deletions

View file

@ -2,7 +2,7 @@
# Maintainer: Sicelo <absicsz@gmail.com>
# Co-Maintainer: Danct12 <danct12@disroot.org>
pkgname=device-nokia-n900
pkgver=9.1.10
pkgver=9.2
pkgrel=0
pkgdesc="Nokia N900"
url="https://postmarketos.org"
@ -149,7 +149,7 @@ xkeyboard_config() {
i3wm() {
install_if="$pkgname postmarketos-ui-i3wm"
depends="unclutter-xfixes feh i3blocks rxvt-unicode"
depends="unclutter-xfixes feh i3blocks rxvt-unicode upower"
install -D -m644 "$srcdir"/i3wm.conf \
"$subpkgdir"/etc/skel/.config/i3/config
install -D -m644 "$srcdir"/i3blocks.conf \
@ -198,7 +198,7 @@ f48b8dd7297d03008f73e1ecd55b77ace535ecb03f9bdf021123b96fb5f4fb491ff4c532e226b835
826a3790b49324c1e61c75b6c0ffc043a2a1d7c13a8c554fb5eae4977af47a1ca93d70ef8c783d712b953b70e18ae58fa4c6a49bf97263398a01a0c4f91ebc8f i3blocks.conf
2b26f551b86c5d71119a518d18b49c3c6a9a6cfcc1ce4f19bb533ce415c698b1b3f200071e3f54b1abb11d8ae1add348e0a3f01ce21805607dd7beebdebf72c0 i3wm.conf
0b80af9fd1f36e6bc06bdfdf48352897234ac7457210649016665da8570a5a64b8a0841b4fbeb64fd7054a5246a64718cf4412f8a53024ce39b28a80984972d8 protip_shell.sh
2ae4771eda9b151de3b47dc4e3081eb86b92fc04c4be4b4fbb98c28016762d24008e935bbba8f95ea0732019f615ee43f5d93dacb21bdc3471e505a07a684e26 battery-bq27200
6c6a70667f37807089adbb343c09d1f62d47b8e6c9c0a54f44790b822f8bff3dccae73341ef736b799fd6740bbd6e1f48e6e122c2e08520f71f6ad7434a47d2c battery-bq27200
d9ef88c714e9fce8822f63b7a9d7fc3e1ed472c8c876b44ba524d44efea322839f13ddd2fa652420608427ecf7279bfaac302c9b67667f32796ca21da332164d calendar
82038d38f94cb975a8d38914afca49b64957446bef7490ab684efa1df47ede2ea1c769045789bb9fded673345eea01911fbbf85fdb54c28685cad8022bfaafac ofono
d7f79fa0887110b85dfb676bd426fa76764fbbb8093df89184552838ddb703b62500f61d7cfa8decdb75a542e3ef577cc71ee4c12ed14d6a76827a3f5aa13073 wifi

View file

@ -1,37 +1,14 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
upower_batt="/org/freedesktop/UPower/devices/battery_bq27200_0"
upower_data=$(upower -i "$upower_batt" 2> /dev/null)
capacity=$(echo "$upower_data" | awk '/percentage/ {print $NF}')
state=$(echo "$upower_data" | awk '/state/ {print $NF}')
echo "$capacity"
echo "$capacity"
# 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"
if [ "$state" = "charging" ] || [ "$state" = "fully-charged" ]; then
echo "#0099FF"
else
notification="$capacity%/$(( ( chg_full / 1000 ) ))mAh -- $(( ( voltage / 1000 ) ))mV @ $(( ( disch_rate / -1000 ) ))mA"
echo "#FFFFFF"
fi
echo $notification
echo $notification
if [[ $disch_rate -gt 1 ]]; then
echo "#FFFFFF"
else
echo "#0099FF"
fi