wmsl

Block-based window manager status line
git clone https://git.sinitax.com/sinitax/wmsl
Log | Files | Refs | README | LICENSE | sfeed.txt

commit a1fd6304d6ad27c65ccb914be65763287c387089
parent 118ac041ca319a377f8d63bd0f11265c26676e89
Author: Louis Burda <quent.burda@gmail.com>
Date:   Tue, 29 Sep 2020 11:56:01 +0200

Turn previous commit into contrib patch

Diffstat:
Mblocks.def.h | 7+++++++
Acontrib/event.diff | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Mwmsl.c | 15++++-----------
3 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/blocks.def.h b/blocks.def.h @@ -5,6 +5,13 @@ struct block blocks[] = { /* command block-id interval flags */ // { SCRIPT_DIR("example.sh"), 1, 5, READY } + { SCRIPT_DIR("calendar.sh"), 1, 5, READY }, + { SCRIPT_DIR("battery.sh"), 0, 10, READY }, + { SCRIPT_DIR("pulseaudio.sh"), 4, 0, READY }, + { SCRIPT_DIR("protonvpn.sh"), 15, 5, READY }, + { SCRIPT_DIR("ethernet.sh"), 14, 5, READY }, + { SCRIPT_DIR("wireless.sh"), 14, 5, READY }, + { SCRIPT_DIR("powerbtn.sh"), 0, 0, READY }, }; const char delim[] = " | "; diff --git a/contrib/event.diff b/contrib/event.diff @@ -0,0 +1,53 @@ +diff --git a/blocks.def.h b/blocks.def.h +index 25c6f83..2bdb418 100644 +--- a/blocks.def.h ++++ b/blocks.def.h +@@ -1,6 +1,6 @@ + #define SCRIPT_DIR(x) "/opt/wmsl-scripts/" x + +-/* use READY or IDLE to set if script should be run on startup */ ++/* use flags to set the scripts starting behavior */ + + struct block blocks[] = { + /* command block-id interval flags */ +diff --git a/wmsl.c b/wmsl.c +index 8f0d0fd..6a323b9 100644 +--- a/wmsl.c ++++ b/wmsl.c +@@ -13,9 +13,10 @@ + #define OUTPUTMAX 256 + #define STATUSMAX 1024 + +-enum block_state { +- IDLE, +- READY ++enum { ++ IDLE = 0, ++ READY = 1, ++ EVENT = 2 + }; + + struct block { +@@ -69,8 +70,10 @@ signal_handler(int sig, siginfo_t *info, void *context) + debug("received signal for block with id %i\n", block_id); + + for (i = 0; i < ARRSIZE(blocks); i++) { +- if (blocks[i].id == block_id) { ++ if (blocks[i].id == abs(block_id)) { + blocks[i].flags |= READY; ++ if (block_id < 0) ++ blocks[i].flags |= EVENT; + break; + } + } +@@ -104,6 +107,10 @@ update_blocks() + if ((blocks[i].flags & READY) || + blocks[i].sleep_max && blocks[i].sleep_left <= 0.5) { + blocks[i].sleep_left = blocks[i].sleep_max; ++ if (blocks[i].flags & EVENT) ++ setenv("WMSLEVENT", "1", 1); ++ else ++ unsetenv("WMSLEVENT"); + blocks[i].flags = IDLE; + + /* get command output */ diff --git a/wmsl.c b/wmsl.c @@ -13,10 +13,9 @@ #define OUTPUTMAX 256 #define STATUSMAX 1024 -enum { - IDLE = 0, - READY = 1, - EVENT = 2 +enum block_state { + IDLE, + READY }; struct block { @@ -70,10 +69,8 @@ signal_handler(int sig, siginfo_t *info, void *context) debug("received signal for block with id %i\n", block_id); for (i = 0; i < ARRSIZE(blocks); i++) { - if (blocks[i].id == abs(block_id)) { + if (blocks[i].id == block_id) { blocks[i].flags |= READY; - if (block_id < 0) - blocks[i].flags |= EVENT; break; } } @@ -107,10 +104,6 @@ update_blocks() if ((blocks[i].flags & READY) || blocks[i].sleep_max && blocks[i].sleep_left <= 0.5) { blocks[i].sleep_left = blocks[i].sleep_max; - if (blocks[i].flags & EVENT) - setenv("WMSLEVENT", "1", 1); - else - unsetenv("WMSLEVENT"); blocks[i].flags = IDLE; /* get command output */