Commit be371306767fd90556d3a84528c4ebaa1d7ade1d

Thomas de Grivel 2019-12-23T22:04:14

OpenBSD config for status bar

diff --git a/bin/battery b/bin/battery
new file mode 100755
index 0000000..7f3132e
--- /dev/null
+++ b/bin/battery
@@ -0,0 +1,5 @@
+#!/bin/sh
+MAX="$(sysctl -n hw.sensors.acpibat0.watthour0 | cut -d ' ' -f 1)"      
+POWER="$(sysctl -n hw.sensors.acpibat0.watthour3 | cut -d ' ' -f 1)" 
+PERCENT=$({ echo scale=1; echo "$POWER*100/$MAX"; } | bc) 
+echo ${PERCENT}%
diff --git a/bin/plugged b/bin/plugged
new file mode 100755
index 0000000..ea6c166
--- /dev/null
+++ b/bin/plugged
@@ -0,0 +1,6 @@
+#!/bin/sh
+if sysctl -n hw.sensors.acpiac0.indicator0 | grep On >/dev/null; then
+    echo "+"
+else
+    false
+fi
diff --git a/bin/status b/bin/status
new file mode 100755
index 0000000..d54ae76
--- /dev/null
+++ b/bin/status
@@ -0,0 +1,2 @@
+#!/bin/sh
+xsetroot -name "$(~/bin/battery)$(~/bin/plugged) $(~/bin/temperature) $(date)"
diff --git a/bin/temperature b/bin/temperature
new file mode 100755
index 0000000..1ff05cd
--- /dev/null
+++ b/bin/temperature
@@ -0,0 +1,4 @@
+#!/bin/sh
+CPUTEMP=$(sysctl -n hw.sensors.cpu0.temp0 | cut -d\  -f 1)
+MBTEMP=$(sysctl -n hw.sensors.pchtemp0.temp0 | cut -d\  -f 1)
+echo "${CPUTEMP}°C ${MBTEMP}°C"