mirror of
https://github.com/mintycube/dwmblocks.git
synced 2024-10-22 14:05:47 +02:00
feat: Add support for block-specific icons
Icons can now be specified on a per-block basis. Closes #64.
This commit is contained in:
parent
8ebe985db8
commit
fe538a7a2f
@ -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. |
|
||||
|
22
config.h
22
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 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)
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user