config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 77e02f9f9066bd97390ddfa9d4391b934d347b62
parent 239abb6c6c294d259d04c314fb61966ea0724bcf
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Mon, 22 Jan 2024 16:17:47 -0800

Add status script

This script writes to '/tmp/status' which is intended to be read
by slstatus(1) and put into the status bar for dwm(1).

Diffstat:
Alocal/bin/bin/status | 48++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+), 0 deletions(-)

diff --git a/local/bin/bin/status b/local/bin/bin/status @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright Sep 2022 Jacob R. Edwards +# +# Temporarily set dwm status (name). +# (Subsequent invokations overwrite the previous message.) + +usage() { + echo "${1:+error: $1 +}usage: ${0##*/} [-s] [-v progress] [-u urgency] subject [message]" 1>&2 + exit 1 +} + +sticky=false +while test $# -gt 0 +do + case "$1" in + (-s) sticky=true ;; + (-v) value="$2"; shift ;; + (-u) + case "$2" in + (low) level=low ;; + (normal) level= ;; + (high) level=high ;; + (*) usage '-u accepts "low", "normal", or "high"' ;; + esac + shift ;; + (-*) usage "$1 option unknown" ;; + (*) break ;; + esac + shift +done + +if test $# -lt 1 -o $# -gt 2 +then + usage 'Invalid number of arguments' +fi + +sub="$1" +msg="${2:-"$(sed 1q)"}" +msg="${level:+"[$level] "}$sub${msg:+": $msg"}${value:+" [$value%]"}" +echo "$msg" > /tmp/status +if ! $sticky +then + mtim=$(stat -f %m /tmp/status) + sleep 4 + test $mtim -eq $(stat -f %m /tmp/status) && + rm /tmp/status +fi