Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using dwmblocks instead of xsetroot #23

Open
frostyfalls opened this issue May 28, 2024 · 0 comments
Open

Consider using dwmblocks instead of xsetroot #23

frostyfalls opened this issue May 28, 2024 · 0 comments

Comments

@frostyfalls
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant