mirror of
https://github.com/kolunmi/dwlb.git
synced 2025-09-06 11:24:45 +00:00
Add -status-stdin command
This commit is contained in:
parent
58bb8ad713
commit
04a218fb4e
@ -64,7 +64,7 @@ Run `dwlb -h` for a full list of options.
|
||||
## Someblocks
|
||||
To use someblocks, or any program that outputs to stdout, with dwlb, use this one-liner:
|
||||
```bash
|
||||
someblocks -p | while read -r line; do dwlb -status all "$line"; done
|
||||
someblocks -p | dwlb -status-stdin all
|
||||
```
|
||||
|
||||
## Acknowledgements
|
||||
|
15
dwlb.c
15
dwlb.c
@ -96,6 +96,7 @@
|
||||
" -scale [BUFFER_SCALE] specify buffer scale value for integer scaling\n" \
|
||||
"Commands\n" \
|
||||
" -status [OUTPUT] [TEXT] set status text\n" \
|
||||
" -status-stdin [OUTPUT] set status text from stdin\n" \
|
||||
" -title [OUTPUT] [TEXT] set title text, if -custom-title is enabled\n" \
|
||||
" -show [OUTPUT] show bar\n" \
|
||||
" -hide [OUTPUT] hide bar\n" \
|
||||
@ -107,6 +108,8 @@
|
||||
" -v get version information\n" \
|
||||
" -h view this help text\n"
|
||||
|
||||
#define TEXT_MAX 2048
|
||||
|
||||
typedef struct {
|
||||
pixman_color_t color;
|
||||
bool bg;
|
||||
@ -121,7 +124,7 @@ typedef struct {
|
||||
} Button;
|
||||
|
||||
typedef struct {
|
||||
char text[2048];
|
||||
char text[TEXT_MAX];
|
||||
Color *colors;
|
||||
uint32_t colors_l, colors_c;
|
||||
Button *buttons;
|
||||
@ -1578,6 +1581,16 @@ main(int argc, char **argv)
|
||||
DIE("Option -status requires two arguments");
|
||||
client_send_command(&sock_address, argv[i], "status", argv[i + 1]);
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "-status-stdin")) {
|
||||
if (++i >= argc)
|
||||
DIE("Option -status-stdin requires an argument");
|
||||
char *status = malloc(TEXT_MAX * sizeof(char));
|
||||
while (fgets(status, TEXT_MAX-1, stdin)) {
|
||||
status[strlen(status)-1] = '\0';
|
||||
client_send_command(&sock_address, argv[i], "status", status);
|
||||
}
|
||||
free(status);
|
||||
return 0;
|
||||
} else if (!strcmp(argv[i], "-title")) {
|
||||
if (++i + 1 >= argc)
|
||||
DIE("Option -title requires two arguments");
|
||||
|
Loading…
x
Reference in New Issue
Block a user