removed icons in setup, increased max length

This commit is contained in:
Alexander Bocken 2020-08-23 17:03:09 +02:00
parent 0a171e708c
commit bf7d745a73
2 changed files with 22 additions and 20 deletions

View File

@ -1,19 +1,24 @@
//Modify this file to change what commands output to your statusbar, and recompile using the make command. //Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = { static const Block blocks[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"", "music", 3600, 11}, {"music", 3600, 11},
{"", "cat /tmp/mucc_time", 100, 3}, {"cat /tmp/mucc_time 2> /dev/null", 100, 3},
{"", "getpomminutesft", 100, 3}, {"getpomminutesft", 100, 3},
{"", "getpomminutes", 100, 3}, {"getpomminutes", 100, 3},
/* {"", "weather", 3600, 5},*/ /* {"weather", 3600, 5},*/
{"", "cpu", 5, 0}, {"pacpackages", 100, 0},
{"", "getmail", 20, 13}, {"cpu", 5, 0},
{"", "news", 600, 13}, // {"nettraf", 10, 0},
{"", "getbright", 4, 2}, {"torrent", 6, 0},
{"", "volume", 1, 10}, {"getmail", 20, 13},
{"", "clock", 10, 0}, {"news", 600, 13},
{"", "internet", 10, 0}, {"getbright", 4, 2},
{"headset_connected", 5, 4},
{"volume", 1, 10},
{"current_day", 100, 0},
{"clock", 4, 0},
{"internet", 10, 0},
}; };
//sets delimeter between status commands. NULL character ('\0') means no delimeter. //sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim = '|'; static char delim = ' ';

View File

@ -5,10 +5,9 @@
#include<signal.h> #include<signal.h>
#include<X11/Xlib.h> #include<X11/Xlib.h>
#define LENGTH(X) (sizeof(X) / sizeof (X[0])) #define LENGTH(X) (sizeof(X) / sizeof (X[0]))
#define CMDLENGTH 50 #define CMDLENGTH 100
typedef struct { typedef struct {
char* icon;
char* command; char* command;
unsigned int interval; unsigned int interval;
unsigned int signal; unsigned int signal;
@ -34,7 +33,7 @@ static Display *dpy;
static int screen; static int screen;
static Window root; static Window root;
static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0}; static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
static char statusstr[2][256]; static char statusstr[2][512];
static int statusContinue = 1; static int statusContinue = 1;
static void (*writestatus) () = setroot; static void (*writestatus) () = setroot;
@ -49,15 +48,13 @@ void replace(char *str, char old, char new)
//opens process *cmd and stores output in *output //opens process *cmd and stores output in *output
void getcmd(const Block *block, char *output) void getcmd(const Block *block, char *output)
{ {
strcpy(output, block->icon);
char *cmd = block->command; char *cmd = block->command;
FILE *cmdf = popen(cmd,"r"); FILE *cmdf = popen(cmd,"r");
if (!cmdf) if (!cmdf)
return; return;
char c; char c;
int i = strlen(block->icon); fgets(output, CMDLENGTH, cmdf);
fgets(output+i, CMDLENGTH-i, cmdf); int i = strlen(output);
i = strlen(output);
if (delim != '\0' && --i) if (delim != '\0' && --i)
output[i++] = delim; output[i++] = delim;
output[i++] = '\0'; output[i++] = '\0';