ChrisTitusTech / dwm-titus

My DWM configuration with everything pre-patched
MIT License
78 stars 46 forks source link

Consider using dwmblocks instead of xsetroot #23

Open st0rmw1ndz opened 1 month ago

st0rmw1ndz commented 1 month ago

Hey Titus, not an issue per se, but using xsetroot (and trap) is a pretty clunky way of getting a status bar inside dwm. I'd recommend using dwmblocks-async, which allows for each block to have a separate update interval, clickable status messages, and signalling via kill for immediate updates (like a volume percentage).

For some examples you can see my statusbar scripts here, as well as my custom build of dwmblocks-async here. Luke Smith and the creator of dwmblocks-async both also have some status bar scripts you could take a look at.

I've also gotten togglable scripts that let you see different things working using temp files, with a script that looks something like this:

#!/bin/sh

# shellcheck disable=SC2015

ALTERNATE_FILE="/tmp/blocks_system"

case "$BLOCK_BUTTON" in
    1) [ -f "$ALTERNATE_FILE" ] && rm "$ALTERNATE_FILE" || touch "$ALTERNATE_FILE" ;;
    3) setsid -f "$TERMINAL" -e htop ;;
    6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

if [ -f "$ALTERNATE_FILE" ]; then
    value=$(top -b -n 1 | awk '/%Cpu\(s\)/{print int($2)"%"}')
    icon="<U+E266>"
else
    value=$(free -h | awk '/Mem/ {print $3"/"$2}' | sed 's/Gi/G/g; s/Mi/M/g')
    icon="<U+EFC5>"
fi

echo "$icon $value"

Preview