Skip to content

Commit

Permalink
Add options to pad left and right side statusbar
Browse files Browse the repository at this point in the history
  • Loading branch information
flipMWD committed Jan 7, 2022
1 parent ba866be commit 9485fa2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions blocks.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ static const Block blocks[] = {
//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | ";
static unsigned int delimLen = 5;

// Sets delimiters around the full statusbar. NULL character ('\0') means no delimeter.
static char leftpad[] = " ";
static char rightpad[] = " ";
7 changes: 6 additions & 1 deletion dwmblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#define LENGTH(X) (sizeof(X) / sizeof (X[0]))
#define CMDLENGTH 50
#define MIN( a, b ) ( ( a < b) ? a : b )
#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1)
#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1 + \
LENGTH(leftpad) + LENGTH(rightpad))

typedef struct {
char* icon;
Expand Down Expand Up @@ -119,9 +120,13 @@ int getstatus(char *str, char *last)
{
strcpy(last, str);
str[0] = '\0';
if (leftpad[0] != '\0')
strcat(str, leftpad);
for (unsigned int i = 0; i < LENGTH(blocks); i++)
strcat(str, statusbar[i]);
str[strlen(str)-strlen(delim)] = '\0';
if (rightpad[0] != '\0')
strcat(str, rightpad);
return strcmp(str, last);//0 if they are the same
}

Expand Down

0 comments on commit 9485fa2

Please sign in to comment.