mirror of
https://github.com/mintycube/dwmblocks.git
synced 2024-10-22 14:05:47 +02:00
Add TRAILING_DELIMITER option
This commit is contained in:
parent
68ffb1f8ed
commit
034f33bc41
@ -89,6 +89,9 @@ Apart from that you can also modify the block delimiters and width of each block
|
||||
#define CMDLENGTH 50
|
||||
|
||||
#define DELIMITER " "
|
||||
|
||||
// Adds a trailing delimiter to the statusbar, useful for powerline
|
||||
#define TRAILING_DELIMITER
|
||||
```
|
||||
|
||||
### Signalling changes
|
||||
|
3
config.h
3
config.h
@ -1,8 +1,9 @@
|
||||
#define CMDLENGTH 50
|
||||
#define DELIMITER "<"
|
||||
#define TRAILING_DELIMITER
|
||||
|
||||
const Block blocks[] = {
|
||||
BLOCK("sb-mail", 1800, 17)
|
||||
BLOCK("sb-mail", 1800, 17)
|
||||
BLOCK("sb-music", 0, 18)
|
||||
BLOCK("sb-disk", 1800, 19)
|
||||
BLOCK("sb-memory", 1800, 20)
|
||||
|
16
main.c
16
main.c
@ -45,14 +45,13 @@ void replace(char *str, char old, char new) {
|
||||
}
|
||||
|
||||
void getCommand(int i, const char *button) {
|
||||
const Block *block = blocks + i;
|
||||
if (fork() == 0) {
|
||||
dup2(pipeFD[1], STDOUT_FILENO);
|
||||
close(pipeFD[0]);
|
||||
|
||||
if (button)
|
||||
setenv("BLOCK_BUTTON", button, 1);
|
||||
execl("/bin/sh", "sh", "-c", block->command);
|
||||
execl("/bin/sh", "sh", "-c", blocks[i].command);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,9 +70,13 @@ void getSignalCommand(int signal) {
|
||||
int getStatus(char *new, char *old) {
|
||||
strcpy(old, new);
|
||||
new[0] = 0;
|
||||
|
||||
for (int i = 0; i < LEN(blocks); i++) {
|
||||
const Block *block = blocks + i;
|
||||
if (strlen(outputs[i]) > (block->signal > 0))
|
||||
#ifdef TRAILING_DELIMITER
|
||||
if (strlen(outputs[i]) > (blocks[i].signal > 0))
|
||||
#else
|
||||
if (strlen(new) && strlen(outputs[i]) > (blocks[i].signal > 0))
|
||||
#endif
|
||||
strcat(new, DELIMITER);
|
||||
strcat(new, outputs[i]);
|
||||
}
|
||||
@ -133,10 +136,9 @@ void childHandler() {
|
||||
// Clear the pipe until newline
|
||||
while (ch != '\n' && read(pipeFD[0], &ch, 1) == 1);
|
||||
|
||||
const Block *block = blocks + i;
|
||||
char *output = outputs[i];
|
||||
if (block->signal > 0) {
|
||||
output[0] = block->signal;
|
||||
if (blocks[i].signal > 0) {
|
||||
output[0] = blocks[i].signal;
|
||||
output++;
|
||||
}
|
||||
strcpy(output, buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user