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