statusbar_text

Purpose: output text to write to the Xorg statusbar.
Usage: statusbar_text

I picked what to show based on my system and personal preferences. You may want different information, or need to adapt things for your system, but this should be a good starting point.

Download statusbar_text

Changelog:
2023-230 and before: initial development
2023-235 reformat/redocument a tad, change network message

Source code (perhaps slightly corrupted) is as follows.

# network connection
LQ=`cat /proc/net/wireless | grep wlan0 | cut -d ' ' -f 6`
LQ="${LQ%.*}"
if [ -z "$LQ" ]
then
    NETCONN='?'
elif [ "$LQ" -ge 50 ]
then
    NETCONN='^'
elif [ "$LQ" -ge 38 ]
then
    NETCONN='~'
elif [ "$LQ" -ge 32 ]
then
    NETCONN='-'
else
    NETCONN='_'
fi

# processor load
LOADLINE=`cat /proc/loadavg`
LOADCUR="${LOADLINE%% *}"
LOADPCT=`printf '%f*100
' "$LOADCUR" | bc`
LOADPCT="${LOADPCT%%.*}"
# processor temperature
THERMLINE=`sensors | grep '^Core 2:' | sed 's/ +/	/g'`
THERMNUM=`echo "$THERMLINE" | cut -f 3`
THERMNUM="${THERMNUM#+}"

# memory usage
MEMLINE=`free | head -n 2 | tail -n 1 | sed 's/ +/	/g'`
MEMN=`echo "$MEMLINE" | cut -f 3`
MEMF=`echo "$MEMLINE" | cut -f 2`
MEMP="$((100*MEMN/MEMF))"

# battery direction
BBP='/sys/class/power_supply/BAT0'
BATTD="$(cat "${BBP}/status")"
case "$BATTD" in
    "Charging") BATTI='>' ;;
    "Full") BATTI='=' ;;
    "Discharging") BATTI='<' ;;
    "Unknown") BATTI='?' ;;
esac
# battery charge
# adapted from https://dwm.suckless.org/status_monitor/batterystatus.c
BATTN="$(cat "${BBP}/charge_now")"
BATTF="$(cat "${BBP}/charge_full")"
BATTP="$((1000*BATTN/BATTF))"
BATTW="$((BATTP/10))"
BATTR="$((BATTP-BATTP/10*10))"
BATTP="${BATTW}.${BATTR}"

# date
FD=`date '+%y-%jT%H'`

echo "net ${NETCONN} | ${LOADPCT}% load | ${THERMNUM} | ${MEMP}% mem | ${BATTI}${BATTP}% batt | ${FD}"

All scripts | dkl9 home