status

dwm status bar
git clone git://git.rr3.xyz/status | git clone gits://git.rr3.xyz/status
Log | Files | Refs | README

commit 65203fb7b682742eed931360cd255070c5ef8845
parent 864a1939f8030602e5e56bb782d38d78d73d184c
Author: Robert Russell <robert@rr3.xyz>
Date:   Sun, 26 Jul 2026 22:44:55 -0700

Use less-stupid names

Diffstat:
MMakefile | 18+++++++++---------
MREADME | 2+-
Astatus_update | 44++++++++++++++++++++++++++++++++++++++++++++
Dstatusupd | 44--------------------------------------------
Rvolget -> volume_get | 0
Rvolset -> volume_set | 0
6 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/Makefile b/Makefile @@ -7,16 +7,16 @@ all: install: mkdir -p $(DESTDIR)$(BINDIR) - cp -f statusupd $(DESTDIR)$(BINDIR)/statusupd - chmod 755 $(DESTDIR)$(BINDIR)/statusupd - cp -f volget $(DESTDIR)$(BINDIR)/volget - chmod 755 $(DESTDIR)$(BINDIR)/volget - cp -f volset $(DESTDIR)$(BINDIR)/volset - chmod 755 $(DESTDIR)$(BINDIR)/volset + cp -f status_update $(DESTDIR)$(BINDIR)/status_update + chmod 755 $(DESTDIR)$(BINDIR)/status_update + cp -f volume_get $(DESTDIR)$(BINDIR)/volume_get + chmod 755 $(DESTDIR)$(BINDIR)/volume_get + cp -f volume_set $(DESTDIR)$(BINDIR)/volume_set + chmod 755 $(DESTDIR)$(BINDIR)/volume_set uninstall: - rm -f $(DESTDIR)$(BINDIR)/statusupd - rm -f $(DESTDIR)$(BINDIR)/volget - rm -f $(DESTDIR)$(BINDIR)/volset + rm -f $(DESTDIR)$(BINDIR)/status_update + rm -f $(DESTDIR)$(BINDIR)/volume_get + rm -f $(DESTDIR)$(BINDIR)/volume_set .PHONY: all install uninstall diff --git a/README b/README @@ -1,3 +1,3 @@ Put, e.g., - while true; do statusupd; sleep 5; done & + while true; do status_update; sleep 5; done & in ~/.xinitrc. diff --git a/status_update b/status_update @@ -0,0 +1,44 @@ +#!/bin/sh +[ $# -eq 0 ] || { echo "usage: $0" >&2; exit 1; } + +VOLUME="$(volume_get)" +DATETIME="$(date +"%a %d %b │ %H:%M")" + +BAT="/sys/class/power_supply/BAT0/capacity" +if [ -r "$BAT" ]; then + BATTERY="$(cat "$BAT")" + xsetroot -name " V${VOLUME}% │ B${BATTERY}% │ $DATETIME " +else + xsetroot -name " V${VOLUME}% │ $DATETIME " +fi + +VERY_LOW_THRESH=10 +LOW_THRESH=20 + +VERY_HIGH_THRESH=90 +HIGH_THRESH=80 + +STATE_DIR="$XDG_RUNTIME_DIR" +STATE="$STATE_DIR/last_status_update_battery" + +if [ -r "$BAT" ] && [ -d "$STATE_DIR" ] && [ -w "$STATE_DIR" ]; then + if [ ! -e "$STATE" ]; then + echo 100 > "$STATE" + fi + + LAST="$(cat "$STATE")" + + if [ "$BATTERY" -le $VERY_LOW_THRESH ] && [ "$LAST" -gt $VERY_LOW_THRESH ]; then + notify-send --urgency=critical "Very low battery (${BATTERY}%)!" + elif [ "$BATTERY" -le $LOW_THRESH ] && [ "$LAST" -gt $LOW_THRESH ]; then + notify-send --urgency=normal "Low battery (${BATTERY}%)!" + fi + + if [ "$BATTERY" -ge $VERY_HIGH_THRESH ] && [ "$LAST" -lt $VERY_HIGH_THRESH ]; then + notify-send --urgency=critical "Very high battery (${BATTERY}%)!" + elif [ "$BATTERY" -ge $HIGH_THRESH ] && [ "$LAST" -lt $HIGH_THRESH ]; then + notify-send --urgency=normal "High battery (${BATTERY}%)!" + fi + + echo "$BATTERY" > "$STATE" +fi diff --git a/statusupd b/statusupd @@ -1,44 +0,0 @@ -#!/bin/sh -[ $# -eq 0 ] || { echo "usage: $0" >&2; exit 1; } - -VOLUME="$(volget)" -DATETIME="$(date +"%a %d %b │ %H:%M")" - -BAT="/sys/class/power_supply/BAT0/capacity" -if [ -r "$BAT" ]; then - BATTERY="$(cat "$BAT")" - xsetroot -name " V${VOLUME}% │ B${BATTERY}% │ $DATETIME " -else - xsetroot -name " V${VOLUME}% │ $DATETIME " -fi - -VERY_LOW_THRESH=10 -LOW_THRESH=20 - -VERY_HIGH_THRESH=90 -HIGH_THRESH=80 - -STATE_DIR="$XDG_RUNTIME_DIR" -STATE="$STATE_DIR/last_statusupd_battery" - -if [ -r "$BAT" ] && [ -d "$STATE_DIR" ] && [ -w "$STATE_DIR" ]; then - if [ ! -e "$STATE" ]; then - echo 100 > "$STATE" - fi - - LAST="$(cat "$STATE")" - - if [ "$BATTERY" -le $VERY_LOW_THRESH ] && [ "$LAST" -gt $VERY_LOW_THRESH ]; then - notify-send --urgency=critical "Very low battery (${BATTERY}%)!" - elif [ "$BATTERY" -le $LOW_THRESH ] && [ "$LAST" -gt $LOW_THRESH ]; then - notify-send --urgency=normal "Low battery (${BATTERY}%)!" - fi - - if [ "$BATTERY" -ge $VERY_HIGH_THRESH ] && [ "$LAST" -lt $VERY_HIGH_THRESH ]; then - notify-send --urgency=critical "Very high battery (${BATTERY}%)!" - elif [ "$BATTERY" -ge $HIGH_THRESH ] && [ "$LAST" -lt $HIGH_THRESH ]; then - notify-send --urgency=normal "High battery (${BATTERY}%)!" - fi - - echo "$BATTERY" > "$STATE" -fi diff --git a/volget b/volume_get diff --git a/volset b/volume_set