summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormdw <mdw@sdf.org>2024-04-20 22:11:31 +0300
committermdw <mdw@sdf.org>2024-04-20 22:11:31 +0300
commit867eaaaf757694aa994add2a5b9815adc3b5db46 (patch)
treea70a4ef101728e0adfa1ee2368f5a07d99bd5cb8
Initial commit
-rw-r--r--.cwmrc3
-rw-r--r--.xsession1
-rwxr-xr-xtermbar.sh80
3 files changed, 84 insertions, 0 deletions
diff --git a/.cwmrc b/.cwmrc
new file mode 100644
index 0000000..d3dbd2c
--- /dev/null
+++ b/.cwmrc
@@ -0,0 +1,3 @@
+ignore "xconsole"
+ignore "termbar"
+gap 26 0 0 0
diff --git a/.xsession b/.xsession
new file mode 100644
index 0000000..4030f99
--- /dev/null
+++ b/.xsession
@@ -0,0 +1 @@
+exec xterm -fs 14 -bg "#1d1f21" -fg "#c5c8c6" -name termbar -class termbar -T termbar -e ~/bin/termbar.sh &
diff --git a/termbar.sh b/termbar.sh
new file mode 100755
index 0000000..9726c6a
--- /dev/null
+++ b/termbar.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+#trap 'exec $0' HUP # Restart itself
+#trap 'tput cnorm; exit 1' INT QUIT TERM
+
+esc="\033"
+reset="${esc}[0m"
+redf="${esc}[31m"
+cyanf="${esc}[36m";
+purplef="${esc}[35m"
+pipe="${purplef}|${reset}"
+
+today()
+{
+ DATE=$(date "+%Y-%m-%d %H:%M")
+}
+
+obsd_ver()
+{
+ VER=$(uname -sr)
+}
+
+cpu()
+{
+ CPU_SPEED=$(printf "%4s" $(sysctl hw.cpuspeed | cut -d "=" -f 2 | cut -d "." -f 1))
+ CPU_TEMP=$(printf "%2s" $(sysctl hw.sensors.acpitz0 | cut -d "=" -f 2 | cut -d "." -f 1))
+}
+
+bat()
+{
+ BAT=$(apm -l)
+}
+
+bat_status()
+{
+ STATUS=$(sysctl hw.sensors.acpiac0.indicator0 | grep -c On)
+
+ if [ ${STATUS} -eq "1" ]; then
+ BAT_STATUS=$(echo Connected)
+ else
+ BAT_STATUS=$(echo ${redf}Disconnected${reset})
+ fi
+}
+
+mem()
+{
+ MEM=$(top -n | grep Memory | awk {'print $6'})
+}
+
+disk()
+{
+ DISK=$(df -h | grep /home | awk {'print $4'})
+}
+
+audio()
+{
+ MUTE=$(sndioctl | grep output.mute | cut -d "=" -f 2)
+ if [ ${MUTE} -eq "1" ]; then
+ VOLUME=$(echo ${redf}Muted${reset})
+ else
+ VOLUME=$(sndioctl | grep output.level | cut -d "=" -f 2)
+ fi
+}
+
+tput civis
+
+while true; do
+ today
+ obsd_ver
+ cpu
+ mem
+ bat
+ bat_status
+ disk
+ audio
+ tput cup 1 0
+ printf "[${VER}] ${pipe} ${DATE} ${pipe} ${cyanf}CPU:${reset} ${CPU_SPEED} MHz (${CPU_TEMP} °C) ${pipe} ${cyanf}RAM:${reset} ${MEM} "
+ printf "${pipe} /home: ${DISK} ${pipe} ${cyanf}Bat:${reset} $BAT - ${BAT_STATUS} ${pipe} ${cyanf}Audio:${reset} ${VOLUME}"
+ sleep 1
+done