From 5ba902a6663dd298f2967fc7e9d691528c0d9ecd Mon Sep 17 00:00:00 2001 From: Aidan Date: Sun, 24 Mar 2019 21:51:40 -0600 Subject: [PATCH] Added function declarations and renamed setrootcmd to statusstr. --- dwmblocks.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/dwmblocks.c b/dwmblocks.c index 62908da..5569531 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -3,16 +3,26 @@ #include #include #include -//#include #include -//#include #define LENGTH(X) (sizeof(X) / sizeof (X[0])) + typedef struct { char* command; unsigned int interval; unsigned int signal; } Block; void sighandler(int num); +void replace(char *str, char old, char new); +void getcmds(int time); +void getsigcmds(int signal); +void setupsignals(); +void getstatus(char *str); +void setroot(); +void statusloop(); +void statusinit(); +void sighandler(int signum); +void termhandler(int signum); + #include "blocks.h" @@ -20,7 +30,7 @@ static Display *dpy; static int screen; static Window root; static char statusbar[LENGTH(blocks)][50] = {0}; -static char setrootcmd[256]; +static char statusstr[256]; static char *statuscat; static const char *volupcmd[] = { "volup", NULL }; static const char *voldowncmd[] = { "voldown", NULL }; @@ -35,7 +45,7 @@ void replace(char *str, char old, char new) str[i] = new; } - +//opens process *cmd and stores output in *output void getcmd(char *cmd, char *output) { FILE *cmdf = popen(cmd,"r"); @@ -84,12 +94,11 @@ void setupsignals() void getstatus(char *str) { - int j = 0;//15; + int j = 0; for(int i = 0; i < 5; j+=strlen(statusbar[i++])) { strcpy(str + j, statusbar[i]); } - //for (;j < LENGTH(str);j++) str[j] = '\0'; } @@ -102,16 +111,15 @@ void setroot() } screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); - getstatus(setrootcmd); - replace(setrootcmd,'\n',' '); - replace(setrootcmd,EOF,' '); - //printf("%s\n",setrootcmd); - XStoreName(dpy, root, setrootcmd); + getstatus(statusstr); + replace(statusstr,'\n',' ');//gets rid of newlines from output + replace(statusstr,EOF,' ');//gets rid of EOF from output + XStoreName(dpy, root, statusstr); XCloseDisplay(dpy); } -void *statusloop() +void statusloop() { setupsignals(); int i = 0; -- 2.39.2