diff --git a/bin/st-bat b/bin/st-bat deleted file mode 100755 index b681ab5..0000000 --- a/bin/st-bat +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -VOLTAGE=$(cat /sys/class/power_supply/BAT1/voltage_now) -CURRENT=$(cat /sys/class/power_supply/BAT1/current_now) -POWER="$(echo "scale=2; $VOLTAGE*$CURRENT/1000000000000" | bc)W" -CHARGE="$(cat /sys/class/power_supply/BAT*/capacity)%" -echo "$CHARGE $POWER" -#echo $POWER >> .power_log diff --git a/bin/st-power b/bin/st-power index f8ed782..d2fcd6f 100755 --- a/bin/st-power +++ b/bin/st-power @@ -1,8 +1,25 @@ #!/bin/sh -POWER="$(pwrstat -status | grep "Load" | awk '{print $2}')W" -CHARGE=$(pwrstat -status | grep "Battery Capacity" | awk '{print $3$4}') -if [[ "$CHARGE" == "100%" ]]; then - echo $POWER -else - echo "$CHARGE $POWER" -fi + +# for UPS monitoring with pwrstatd +# +#POWER="$(pwrstat -status | grep "Load" | awk '{print $2}')W" +#CHARGE=$(pwrstat -status | grep "Battery Capacity" | awk '{print $3$4}') +#if [[ "$CHARGE" == "100%" ]]; then +# echo $POWER +#else +# echo "$CHARGE $POWER" +#fi + +# for battery monitoring everywhere else +# +# if power_now is not present, calculate it: +#VOLTAGE=$(cat /sys/class/power_supply/BAT*/voltage_now) +#CURRENT=$(cat /sys/class/power_supply/BAT*/current_now) +#POWER=$(echo "scale=2; $VOLTAGE*$CURRENT/1000000000000" | bc) + +# if it is present, just divide it to watts (from micro watts on thinkpads, perhaps something else on other platforms) +POWER=$(cat /sys/class/power_supply/BAT*/power_now) +POWER="$(echo "scale=2; $POWER/1000000" | bc)W" +CHARGE="$(cat /sys/class/power_supply/BAT*/capacity)%" + +echo "$CHARGE $POWER"