[BACK]Return to termbar CVS log [TXT][DIR] Up to [x61] / dotfiles / termbar

Annotation of dotfiles/termbar/termbar, Revision 1.4

1.1       gonzalo     1: #!/bin/sh
                      2:
1.3       gonzalo     3: ## Debug
                      4: #set -x
1.1       gonzalo     5:
1.3       gonzalo     6: esc="\033"
                      7: reset="${esc}[0m"
                      8: redf="${esc}[31m"
                      9: cyanf="${esc}[36m";
                     10: purplef="${esc}[35m"
                     11: pipe="${purplef}|${reset}"
1.2       gonzalo    12:
1.3       gonzalo    13: today()
                     14: {
                     15:        DATE=$(date +"%B %d - %H:%M")
                     16: }
                     17:
                     18: cpu()
                     19: {
1.1       gonzalo    20:        CPU_TEMP=$(sysctl hw.sensors.cpu0.temp0 | cut -d "=" -f 2 | cut -d "." -f 1)
1.4     ! gonzalo    21:        CPU_SPEED=$(printf "%4s" $(sysctl hw.cpuspeed | cut -d "=" -f 2 | cut -d "." -f 1))
1.3       gonzalo    22: }
                     23:
                     24: bat()
                     25: {
1.1       gonzalo    26:        BAT=$(apm -l)
1.3       gonzalo    27: }
                     28:
                     29: bat_status()
                     30: {
                     31:        STATUS=$(sysctl hw.sensors.acpiac0.indicator0 | grep -c On)
                     32:
                     33:        if [ ${STATUS} -eq "1" ]; then
                     34:                BAT_STATUS=$(echo Connected)
                     35:        else
                     36:                BAT_STATUS=$(echo ${redf}Disconnected${reset})
                     37:        fi
                     38: }
                     39:
                     40: mem()
                     41: {
                     42:        MEM=$(top -n | grep Memory | awk {'print $6'})
                     43: }
                     44:
                     45: wifi()
                     46: {
                     47:        SSID=$(ifconfig | grep join | sed -e 's/.*join\(.*\)chan.*/\1/')
                     48: }
                     49:
                     50: network()
                     51: {
                     52:        IIP=$(ifconfig trunk0 | grep inet | awk '{print $2}')
                     53:        PIP=$(dig +short myip.opendns.com @resolver1.opendns.com | awk {'printf $1'})
                     54: }
                     55:
                     56: while true; do
                     57:        today
                     58:        cpu
                     59:        mem
                     60:        bat
                     61:        bat_status
                     62:        wifi
                     63:        network
                     64:        printf "  ${DATE} ${pipe} ${cyanf}CPU:${reset} ${CPU_SPEED} MHz (${CPU_TEMP}°) ${pipe} ${cyanf}Mem:${reset} ${MEM} "
                     65:        printf "${pipe} ${cyanf}Bat:${reset} $BAT - ${BAT_STATUS} ${pipe} ${cyanf}SSID:${reset}${SSID}${pipe}"
                     66:        printf " ${cyanf}IPs:${reset} ${PIP} / ${IIP} \v"
                     67:         sleep 15
1.1       gonzalo    68: done

CVSweb
CodeBerg
SourceHut