From d98a3cae654f30318e92f0bd19298d8fbfc37bef Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 7 May 2022 20:57:28 +0200 Subject: execute scripts instead of hardcoded --- README.md | 35 +++++++++++++++++++++++++++++++++++ status | 28 +++++++++++++++++++++------- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eb26d3e..2d1a1d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ # status This is a status script for dwm + +## Modules + +Each module of your statusbar is a scripts that is located under `~/.local/share/status/` + +Each script will be executed in alphanumeric order, so if you want to have +a specific order in which your bar is displayed use numbers as prefix +of your scripts like this: + +``` +~/.local/share/status: + 00_battery + 01_volume + 02_clock + ... +``` + +## Usage + +To start the status daemon use the `-d` flag. +If you want that the statusbar updates a *unit*, for example *01_volume* when +the volume buttons are pressed, just just execute `status -u 01_volume` to +update the unit. + +## Config + +In the config under `~/.config/status/config` you can set the following +variables: + +- CMDFIFO: Where to place the FIFO which is the communication layer between + the daemon and the update requests. (default: ~/.cache/status) +- BINDIR: Where your unit files are stored (default: ~/.local/share/status/) +- AUTOREFRESH: After how many seconds the statusbar should autorefresh (default: 60) + +The config is just sourced into the script so just use *POSIX-Shell* Syntax in it. diff --git a/status b/status index def0663..af5c190 100755 --- a/status +++ b/status @@ -1,27 +1,41 @@ #!/bin/sh CMDFIFO=~/.cache/status +BINDIR=~/.local/share/status +AUTOREFRESH=60 -clockupdate() { +if [ -f "~/.config/status/config" ]; then + source ~/.config/status/config +fi + +mkdir -p $BINDIR + +autorefresh() { while (true); do - echo update clock > $CMDFIFO - sleep 60 + sleep $AUTOREFRESH + echo autoupdate > $CMDFIFO + done +} + +exec_bins() { + for bin in $BINDIR/*; do + $bin done } daemon() { [ ! -p "$CMDFIFO" ] && mkfifo $CMDFIFO - clockupdate & - status() { xsetroot -name " $(cat) " } + autorefresh & + cmd="" while (true); do - echo "$(volume)|$(clock)" | column -t -s '|' | status + exec_bins | sed -zE 's/\n/|/g' | column -t -s '|' | status cmd=$(cat $CMDFIFO) done @@ -37,6 +51,6 @@ help() { case "$1" in -d) daemon;; - -u) echo "$2" > $CMDFIFO;; + -u) echo "update $2" > $CMDFIFO;; -h) help;; esac -- cgit v1.2.3-70-g09d2