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

Annotation of dotfiles/termbar/termbar, Revision 1.6

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

CVSweb
CodeBerg
SourceHut