Skip to content

Commit

Permalink
sys.sh: add support for openbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
kiike committed Oct 7, 2014
1 parent 96ff878 commit 111fcc2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sys.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
# System info for Tmux



TEMP_PATH="/sys/class/thermal/thermal_zone0"
BATT_PATH="/sys/class/power_supply/BAT0/"

Expand All @@ -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
Expand Down

0 comments on commit 111fcc2

Please sign in to comment.