diff --git a/README.md b/README.md index 69b72da..1b389f6 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,8 @@ You can define your status bar blocks in `config.h`: ```c #define BLOCKS(X) \ ... - X("volume", 0, 5), \ - X("date", 1800, 1), \ + X(" ", "wpctl get-volume @DEFAULT_AUDIO_SINK@ | cut -d' ' -f2", 0, 5) \ + X("󰥔 ", "date '+%H:%M:%S'", 1, 1) \ ... ``` @@ -99,6 +99,7 @@ Each block has the following properties: | Property | Description | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| Icon | An icon you wish to prepend to your block output. | | Command | The command you wish to execute in your block. | | Update interval | Time in seconds, after which you want the block to update. If `0`, the block will never be updated. | | Update signal | Signal to be used for triggering the block. Must be a positive integer. If `0`, a signal won't be set up for the block and it will be unclickable. | diff --git a/config.h b/config.h index a02c0ca..d9d605b 100644 --- a/config.h +++ b/config.h @@ -16,17 +16,17 @@ // Control whether a trailing delimiter should be appended to the status. #define TRAILING_DELIMITER 0 -// Define blocks for the status feed as X(cmd, interval, signal). -#define BLOCKS(X) \ - X("sb-mail", 600, 1) \ - X("sb-music", 0, 2) \ - X("sb-disk", 1800, 3) \ - X("sb-memory", 10, 4) \ - X("sb-loadavg", 5, 5) \ - X("sb-mic", 0, 6) \ - X("sb-record", 0, 7) \ - X("sb-volume", 0, 8) \ - X("sb-battery", 5, 9) \ - X("sb-date", 1, 10) +// Define blocks for the status feed as X(icon, cmd, interval, signal). +#define BLOCKS(X) \ + X("", "sb-mail", 600, 1) \ + X("", "sb-music", 0, 2) \ + X("", "sb-disk", 1800, 3) \ + X("", "sb-memory", 10, 4) \ + X("", "sb-loadavg", 5, 5) \ + X("", "sb-mic", 0, 6) \ + X("", "sb-record", 0, 7) \ + X("", "sb-volume", 0, 8) \ + X("", "sb-battery", 5, 9) \ + X("", "sb-date", 1, 10) #endif // CONFIG_H diff --git a/include/block.h b/include/block.h index 555549c..c4f8d54 100644 --- a/include/block.h +++ b/include/block.h @@ -9,6 +9,7 @@ #include "util.h" typedef struct { + const char *const icon; const char *const command; const unsigned int interval; const int signal; @@ -18,8 +19,8 @@ typedef struct { pid_t fork_pid; } block; -block block_new(const char *const command, const unsigned int interval, - const int signal); +block block_new(const char *const icon, const char *const command, + const unsigned int interval, const int signal); int block_init(block *const block); int block_deinit(block *const block); int block_execute(block *const block, const uint8_t button); diff --git a/src/block.c b/src/block.c index 0a73af6..a6c919d 100644 --- a/src/block.c +++ b/src/block.c @@ -13,9 +13,10 @@ #include "config.h" #include "util.h" -block block_new(const char *const command, const unsigned int interval, - const int signal) { +block block_new(const char *const icon, const char *const command, + const unsigned int interval, const int signal) { block block = { + .icon = icon, .command = command, .interval = interval, .signal = signal, diff --git a/src/main.c b/src/main.c index e019765..747b075 100644 --- a/src/main.c +++ b/src/main.c @@ -128,7 +128,8 @@ int main(const int argc, const char *const argv[]) { return 1; } -#define BLOCK(command, interval, signal) block_new(command, interval, signal), +#define BLOCK(icon, command, interval, signal) \ + block_new(icon, command, interval, signal), block blocks[BLOCK_COUNT] = {BLOCKS(BLOCK)}; #undef BLOCK const unsigned short block_count = LEN(blocks); diff --git a/src/status.c b/src/status.c index a3a4794..cf0911a 100644 --- a/src/status.c +++ b/src/status.c @@ -49,6 +49,7 @@ bool status_update(status *const status) { } #endif + (void)strncat(status->current, block->icon, LEN(block->output)); (void)strncat(status->current, block->output, LEN(block->output)); } }