commit ddbaf03490e1f5b6addbed040f561db8069f1285 from: gonzalo date: Wed Sep 30 08:56:30 2020 UTC clean up a bit, kill the cursor and some other nice ideas from tumfatig.net commit - 166bd4e973569c1897500919edf4e6063683afa8 commit + ddbaf03490e1f5b6addbed040f561db8069f1285 blob - 851ea33fe9b2095085405244eaef7df3cd7385c3 blob + 426be2fad95695a09efd05233e9098abaa4410c2 --- termbar/termbar +++ termbar/termbar @@ -3,6 +3,9 @@ ## Debug #set -x +trap 'exec $0' HUP # Restart itself +trap 'tput cnorm; exit 1' INT QUIT TERM + esc="\033" reset="${esc}[0m" redf="${esc}[31m" @@ -12,12 +15,17 @@ pipe="${purplef}|${reset}" today() { - DATE=$(date +"%B %d - %H:%M") + DATE=$(date '+%a %d %b %H:%M') } +desktop_id() +{ + DESKTOP_ID=$(xprop -root 32c '\t$0' _NET_CURRENT_DESKTOP | cut -f 2) +} + cpu() { - CPU_TEMP=$(sysctl hw.sensors.cpu0.temp0 | cut -d "=" -f 2 | cut -d "." -f 1) + CPU_TEMP=$(sysctl hw.sensors.ksmn0.temp0 | cut -d "=" -f 2 | cut -d "." -f 1) CPU_SPEED=$(printf "%4s" $(sysctl hw.cpuspeed | cut -d "=" -f 2 | cut -d "." -f 1)) } @@ -49,20 +57,24 @@ wifi() network() { - IIP=$(ifconfig trunk0 | grep inet | awk '{print $2}') + IIP=$(ifconfig iwm0 | grep inet | awk '{print $2}') PIP=$(dig +short myip.opendns.com @resolver1.opendns.com | awk {'printf $1'}) } +tput civis + while true; do today + desktop_id cpu mem bat bat_status wifi network - printf " ${DATE} ${pipe} ${cyanf}CPU:${reset} ${CPU_SPEED} MHz (${CPU_TEMP}°) ${pipe} ${cyanf}Mem:${reset} ${MEM} " + tput cup 1 0 + printf "[${DESKTOP_ID}] ${DATE} ${pipe} ${cyanf}CPU:${reset} ${CPU_SPEED} MHz (${CPU_TEMP}°) ${pipe} ${cyanf}Mem:${reset} ${MEM} " printf "${pipe} ${cyanf}Bat:${reset} $BAT - ${BAT_STATUS} ${pipe} ${cyanf}SSID:${reset}${SSID}${pipe}" - printf " ${cyanf}IPs:${reset} ${PIP} / ${IIP} \r" - sleep 15 + printf " ${cyanf}IPs:${reset} ${IIP} / ${PIP} \r\r" + sleep 1 done