#!/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} \t \t \t \t" sleep 1 done