commit 3caf4f7a23df9250fbd64cc59e7bd61e59c7ca85 parent 04c817100e07653c93b5e12bb3c57ca6afc2221e Author: hhvn <dev@hhvn.uk> Date: Sun, 25 Apr 2021 14:10:20 +0100 .s/d/bat: use apm(1) on obsd Diffstat:
M | .scripts/dwmblocks/bat | | | 23 | ++++++++++++++++------- |
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/.scripts/dwmblocks/bat b/.scripts/dwmblocks/bat @@ -1,12 +1,21 @@ -#!/bin/bash - -case "$(acpi | awk '{print $3}' | tr -d ',')" in - "Charging") charging=y ;; - "Discharging") discharging=y ;; -esac +#!/bin/sh total=100 -charge=$(acpi | awk '{print $4}' | tr -d ',%') +[ "$(uname)" = "Linux" ] && { + case "$(acpi | awk '{print $3}' | tr -d ',')" in + "Charging") charging=y ;; + "Discharging") discharging=y ;; + esac + charge=$(acpi | awk '{print $4}' | tr -d ',%') +} + +[ "$(uname)" = "OpenBSD" ] && { + case "$(apm | head -n 2 | tail -n 1 | sed 's/.*: //')" in + "not"*) discharging=y ;; + *) charging=y ;; + esac + charge=$(apm | head -n 1 | sed -E 's/%.*//;s/.*([0-9])/\1/') +} num=$(echo "scale=2; ($charge/$total)*21" | bc | sed 's~\..*$~~') ind="^c#aa6600^?" [ "$charging" = "y" ] && ind="^c#00aa00^+"