dwl
installation
sudo pacman -S wlroots wayland-protocols xorg-xwayland kitty keyd wmenu slurp grim wl-clipboard
git clone 'https://github.com/vectorspacexyz/dwl.git'
The patches I applied were:
All of the patches were very straightforward. However I had issues with barcolors patch. Look into drawstatus
function to see the mods I've made (with Claude AI) to get it to work. However even with those mods I wasn't able to display nested fg-bg color formatting like: ^bg(FFFF00)^fg(000000)%s: %d%%^fg()^bg()
.
someblocks without somebar
source: https://sr.ht/~raphi/someblocks/
Yeah so don't bother installing somebar.
You need to apply this patch: https://lists.sr.ht/~raphi/public-inbox/patches/56817
I copied it over to some.patch
//Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"", "$HOME/bin/bar/data.sh", 1, 0},
{"", "$HOME/bin/bar/battery.sh", 5, 10},
{"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0},
{"", "date '+%b %d (%a) %I:%M%p'", 5, 0},
/* Updates whenever "pkill -SIGRTMIN+10 someblocks" is ran */
/* {"", "date '+%b %d (%a) %I:%M%p'", 0, 10}, */
};
//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | ";
static unsigned int delimLen = 5;
#!/bin/bash
# Loop through all attached batteries and format the info
for battery in /sys/class/power_supply/BAT?*; do
# If non-first battery, print a space separator.
[ -n "${capacity+x}" ] && printf " "
# Sets up the status and capacity
case "$(cat "$battery/status" 2>&1)" in
"Full") status="FULL" ;;
"Discharging") status="DISCHARGING" ;;
"Charging") status="CHARGING" ;;
"Not charging") status="NOT CHARGING" ;;
"Unknown") status="UNKNOWN" ;;
*) exit 1 ;;
esac
capacity="$(cat "$battery/capacity" 2>&1)"
# Set colors based on status and capacity
if [ "$status" = "DISCHARGING" ] && [ "$capacity" -le 30 ]; then
# Red background for discharging and below 30%
printf "^bg(FF0000)%s: %d%%^bg()" "$status" "$capacity"
elif [ "$status" = "DISCHARGING" ]; then
# Yellow background for discharging
printf "^fg(FFFF00)%s: %d%%^fg()" "$status" "$capacity"
elif [ "$status" = "CHARGING" ]; then
# Blue background for charging (dwm blue)
printf "^fg(00FF00)%s: %d%%^fg()" "$status" "$capacity"
else
# No background color for other states
printf "%s: %d%%" "$status" "$capacity"
fi
done && printf "\\n"
#!/bin/sh
# Module showing network traffic. Shows the total amount of data that has been
# received (RX) or transmitted (TX) with colored arrows when traffic exceeds 1MB/s.
# Cache file to store previous values
CACHE_FILE="/tmp/network_traffic.cache"
update() {
sum=0
for arg; do
read -r i < "$arg"
sum=$(( sum + i ))
done
echo "$sum"
}
# Get current values
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
# Check for previous values
if [ -f "$CACHE_FILE" ]; then
read -r prev_rx prev_tx < "$CACHE_FILE"
# Calculate differences (bytes)
rx_diff=$(( rx - prev_rx ))
tx_diff=$(( tx - prev_tx ))
# 1MB in bytes
# MB_THRESHOLD=1048576
MB_THRESHOLD=262144
# Set arrow colors based on threshold
if [ "$rx_diff" -ge "$MB_THRESHOLD" ]; then
rx_arrow="^fg(00FF00)⮟^fg()"
else
rx_arrow="⮟"
fi
if [ "$tx_diff" -ge "$MB_THRESHOLD" ]; then
tx_arrow="^fg(FF0000)⮝^fg()"
else
tx_arrow="⮝"
fi
else
# First run, no coloring
rx_arrow="⮟"
tx_arrow="⮝"
fi
# Save current values for next run
echo "$rx $tx" > "$CACHE_FILE"
# Output with potentially colored arrows
printf "%s %sB %s %sB\n" "$rx_arrow" "$(numfmt --to=iec "$rx")" "$tx_arrow" "$(numfmt --to=iec "$tx")"
The battery in the above script works alongside udev rules:
# Rule for when switching to battery
ACTION=="change", SUBSYSTEM=="power_supply", ATTRS{type}=="Mains", ATTRS{online}=="0", \
RUN+="/bin/sh -c 'pgrep someblocks >/dev/null && pkill -SIGRTMIN+10 someblocks || true'"
# Rule for when switching to AC
ACTION=="change", SUBSYSTEM=="power_supply", ATTRS{type}=="Mains", ATTRS{online}=="1", \
RUN+="/bin/sh -c 'pgrep someblocks >/dev/null && pkill -SIGRTMIN+10 someblocks || true'"
Reload udev:
On a related note you can get live battery info with:
getting good glyphs for somebar
https://github.com/Templarian/MaterialDesign-Font
source: https://www.reddit.com/r/archlinux/comments/q03x8j/comment/hf5sdqq
Getting app id
dwlmsg git: https://codeberg.org/notchoc/dwlmsg.git