Merge branch 'master' of github.com:LukeSmithxyz/dwmblocks

This commit is contained in:
Luke Smith 2020-06-02 15:46:11 -04:00
commit d3eed01126
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252
3 changed files with 16 additions and 8 deletions

View file

@ -1,4 +1,6 @@
PREFIX ?= /usr/local .POSIX:
PREFIX = /usr/local
output: dwmblocks.o output: dwmblocks.o
gcc dwmblocks.o -lX11 -o dwmblocks gcc dwmblocks.o -lX11 -o dwmblocks
@ -12,3 +14,5 @@ install: output
chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks
uninstall: uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks
.PHONY: clean install uninstall

View file

@ -2,7 +2,7 @@
static const Block blocks[] = { static const Block blocks[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9},
/* {"", "music", 0, 11}, */ /* {"", "music", 0, 11},*/
{"", "pacpackages", 0, 8}, {"", "pacpackages", 0, 8},
{"", "news", 0, 6}, {"", "news", 0, 6},
/* {"", "crypto", 0, 13}, */ /* {"", "crypto", 0, 13}, */
@ -24,7 +24,7 @@ static const Block blocks[] = {
}; };
//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 = " ";
// Have dwmblocks automatically recompile and run when you edit this file in // Have dwmblocks automatically recompile and run when you edit this file in
// vim with the following line in your vimrc/init.vim: // vim with the following line in your vimrc/init.vim:

View file

@ -75,11 +75,12 @@ void getcmd(const Block *block, char *output)
return; return;
char c; char c;
int i = strlen(block->icon); int i = strlen(block->icon);
fgets(output+i, CMDLENGTH-i, cmdf); fgets(output+i, CMDLENGTH-(strlen(delim)+1), cmdf);
remove_all(output, '\n'); remove_all(output, '\n');
i = strlen(output); i = strlen(output);
if (delim != '\0' && i) if ((i > 0 && block != &blocks[LENGTH(blocks) - 1]))
output[i++] = delim; strcat(output, delim);
i+=strlen(delim);
output[i++] = '\0'; output[i++] = '\0';
pclose(cmdf); pclose(cmdf);
} }
@ -134,8 +135,11 @@ int getstatus(char *str, char *last)
{ {
strcpy(last, str); strcpy(last, str);
str[0] = '\0'; str[0] = '\0';
for(int i = 0; i < LENGTH(blocks); i++) for(int i = 0; i < LENGTH(blocks); i++) {
strcat(str, statusbar[i]); strcat(str, statusbar[i]);
if (i == LENGTH(blocks) - 1)
strcat(str, " ");
}
str[strlen(str)-1] = '\0'; str[strlen(str)-1] = '\0';
return strcmp(str, last);//0 if they are the same return strcmp(str, last);//0 if they are the same
} }
@ -222,7 +226,7 @@ int main(int argc, char** argv)
for(int i = 0; i < argc; i++) for(int i = 0; i < argc; i++)
{ {
if (!strcmp("-d",argv[i])) if (!strcmp("-d",argv[i]))
delim = argv[++i][0]; delim = argv[++i];
else if(!strcmp("-p",argv[i])) else if(!strcmp("-p",argv[i]))
writestatus = pstdout; writestatus = pstdout;
} }