From 111fcc22afe4ec0a3b3efca1e3e21ce625a8991b Mon Sep 17 00:00:00 2001 From: Enric Morales Date: Tue, 7 Oct 2014 19:58:22 +0200 Subject: [PATCH] sys.sh: add support for openbsd --- sys.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys.sh b/sys.sh index 0a89db3..dc77e62 100755 --- a/sys.sh +++ b/sys.sh @@ -1,6 +1,8 @@ #!/bin/sh # System info for Tmux + + TEMP_PATH="/sys/class/thermal/thermal_zone0" BATT_PATH="/sys/class/power_supply/BAT0/" @@ -16,8 +18,16 @@ fi if [ -d ${BATT_PATH} ]; then max_charge="$(< ${BATT_PATH}/energy_full)" cur_charge="$(< ${BATT_PATH}/energy_now)" + +elif [[ "$(uname -s)" == "OpenBSD" ]]; then + cmd="sysctl -n hw.sensors.acpibat0" + max_charge="$(${cmd}.watthour0 | cut -d. -f1)" + cur_charge="$(${cmd}.watthour3 | cut -d. -f1)" +fi + +if [[ -n ${max_charge} ]] && [[ -n ${cur_charge} ]]; then bat="$((100 * $cur_charge / $max_charge))" - echo -n "↯${bat}% | " + echo -n "${bat}% | " fi # Print date