You are not logged in.

#1 2019-09-28 09:45:14

clusterF
Member
Registered: 2019-05-07
Posts: 306

status-bar script for dwm

Hi, just thought i would share something i have been working on, im not the best at scripting so it probably shows! Anyhow this is for anyone running dwm with the extrabar patch. You would need to modify the values to suit your setup such as the /dev/sda3 and network devices. This is the only way i think i could use dwm statusbar and extrabar to its full extent, conky will only output to one statusbar if using xsetroot -name to pipe it there.Its probably overkill and there is possibly a better way maybe putting some of the commands into a longer loop time? Im using startx so i just autostart it from .xinitrc.

https://dwm.suckless.org/patches/extrabar/

#!/usr/bin/env sh
while true; do

        date '+| %A :: %B %d :: %R |' > /tmp/CurTime.tmp

        sleep 60s
done &
while true; do

        LOCALTIME=$(< /tmp/CurTime.tmp)
        DISKFREE=$(df -Ph | grep "/dev/sda3" | awk {'print $4'})
        DISKUSED=$(df -Ph | grep "/dev/sda3" | awk {'print $3'})
        MEM=$(free -h | awk '/^Mem:/ {print $3 "/" $2}')
        LINUX=$(uname -r)
        NET=$(nmcli dev wifi | grep -E '^[*]' | awk '/*/ {print $8}')
        TOTALDOWN=$(ifconfig wlp2s0| grep "RX packets" | awk {'print $6 $7'})
        TOTALUP=$(ifconfig wlp2s0| grep "TX packets" | awk {'print $6 $7'})
        xsetroot -name "$LOCALTIME ; | Kernel:$LINUX | Disk Free:$DISKFREE | Disk Used:$DISKUSED | Mem:$MEM | Net: $NET TotalUp: $TOTALUP TotalDown: $TOTALDOWN |"

        sleep 10s
done &

scrot

2019-09-28-211114-1366x768-scrot.png

Edit: removed the NETDOOWN and NETUP commands, too ugly. Using nmcli one liner just to show connection at the moment, yet to figure out how to properly implement totalup and totaldown  how conky does it.

NETDOWN=$(ifconfig wlan0 | grep "RX" | head -n1 | cut -c39-49)
        NETUP=$(ifconfig wlan0 | grep "TX" | head -n1 | cut -c38-58)

edited for the tenth time: how good is awk !

Last edited by clusterF (2019-09-28 11:23:58)


"Common sense is like deodorant, those who need it the most never use it."

git: clusterF

Offline

#2 2019-09-28 10:56:03

Bridouz
Member
From: France, countryside
Registered: 2019-08-15
Posts: 30
Website

Re: status-bar script for dwm

Nice tip.

You can also use termbar which is a simple terminal resized as a bar.

Scripting is therefore beyond imagination wink.

Offline

#3 2019-09-28 11:03:11

clusterF
Member
Registered: 2019-05-07
Posts: 306

Re: status-bar script for dwm

^ thanks for that, termbar looks rather interesting i will definitely look into it smile


"Common sense is like deodorant, those who need it the most never use it."

git: clusterF

Offline

#4 2019-09-28 11:13:22

clusterF
Member
Registered: 2019-05-07
Posts: 306

Re: status-bar script for dwm

edited op, found a way to have similar totalup and totaldown as conky does it with the use of better grep and awk commands.

        TOTALDOWN=$(ifconfig wlp2s0| grep "RX packets" | awk {'print $6 $7'})
        TOTALUP=$(ifconfig wlp2s0| grep "TX packets" | awk {'print $6 $7'})

"Common sense is like deodorant, those who need it the most never use it."

git: clusterF

Offline

#5 2019-09-28 17:20:00

clusterF
Member
Registered: 2019-05-07
Posts: 306

Re: status-bar script for dwm

here is an updated version for use on my debian/devuan machines.

have to use env bash or else wttr.in for the weather will not work.

#!/usr/bin/env bash
while true; do

        date '+| %A :: %B %d :: %R |' > /tmp/CurTime.tmp

        sleep 60s
done &

while true; do

        LOCALTIME=$(< /tmp/CurTime.tmp)
        DISKROOT=$(df -Ph | grep "/dev/sda1" | awk {'print $5'})
        DISKHOME=$(df -Ph | grep "/dev/sda2" | awk {'print $5'})
        MEM=$(free -h --kilo | awk '/^Mem:/ {print $3 "/" $2}')
        LINUX=$(uname -r)
        TOTALDOWN=$(sudo ifconfig wlan0 | grep "RX packets" | awk {'print $6 $7'})
        TOTALUP=$(sudo ifconfig wlan0 | grep "TX packets" | awk {'print $6 $7'})
        CPU=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
        WEATHER=$(curl wttr.in/Brisbane?format="%l:+%m+%p+%w+%t+%c+%C")
        xsetroot -name " $LOCALTIME;| Kernel: $LINUX | ROOT: $DISKROOT | HOME: $DISKHOME | MEM: $MEM | NET: T/UP: $TOTALUP T/DOWN: $TOTALDOWN | CPU: $CPU | $WEATHER |"

        sleep 10s
done &

"Common sense is like deodorant, those who need it the most never use it."

git: clusterF

Offline

Board footer

Powered by FluxBB