diff --git a/status.c b/status.c index 3a06c0a..ff4b380 100644 --- a/status.c +++ b/status.c @@ -1,4 +1,4 @@ -/* This is a fork of dwmblocks licensed under GNU General Public License version 2. +/* This is a fork of dwmblocks licensed under GNU General Public License version 2. * See LICENSE file for copyright details. */ #define _POSIX_C_SOURCE 200112L @@ -15,6 +15,8 @@ #include #define LENGTH(X) (sizeof(X) / sizeof (X[0])) +int isquit = 0; + typedef struct { char* icon; char* command; @@ -56,6 +58,7 @@ static volatile int statusContinue = 1; static pthread_mutex_t write_mut = PTHREAD_MUTEX_INITIALIZER; static void (*writestatus) () = setroot; + void replace(char *str, char old, char new) { for(char * c = str; *c; c++) @@ -97,7 +100,7 @@ getcmd(const Module *module, char *output) strcpy(output, module->icon); else strcpy(output, ""); - + strcpy(output+i, tmpstr); remove_all(output, '\n'); @@ -177,7 +180,7 @@ int getstatus(char *str, char *last) { strcpy(last, str); - + str[0] = '\0'; if (leftpadding[0] != '\0') strcat(str, leftpadding); @@ -291,6 +294,8 @@ statusloop() while(statusContinue) { syncwrite(); + if (isquit) + exit(0); pause(); } @@ -318,11 +323,22 @@ int main(int argc, char** argv) { for(int i = 0; i < argc; i++) { - if (!strcmp("-d",argv[i])) - separator = argv[++i]; - else if(!strcmp("-p",argv[i])) + if(!strcmp("-p",argv[i])) writestatus = pstdout; + else if(!strcmp("-pq",argv[i])) { + isquit = 1; + writestatus = pstdout; + } else if (!strcmp("-h", argv[i])) { + fputs("status: speedwm status bar\n" + "\nUsage:\n\n" + "status -h Get help with status.\n" + "status -p Run status bar and print text to stdout.\n" + "status -pq Run status bar once and print text to stdout.\n" + , stderr); + exit(0); + } } + signal(SIGTERM, termhandler); signal(SIGINT, termhandler); statusloop(); diff --git a/status.h b/status.h index 3963087..c0e62ce 100644 --- a/status.h +++ b/status.h @@ -24,9 +24,9 @@ static const Module modules[] = { { "<\x03", "module_bat --print", 2, 3 }, { "<\x04", "module_vol --print", 1, 4 }, { "<\x05", "module_ram --print", 6, 5 }, - { "<\x01", "module_net --print", 10, 6 }, + //{ "<\x01", "module_net --print", 10, 6 }, { "<\x02", "module_temp --print", 5, 7 }, - { "<\x03", "module_weather --print", 60, 8 }, + //{ "<\x03", "module_weather --print", 60, 8 }, { "<\x04", "module_music --print", 1, 9 }, { "<\x05", "module_dfmpeg --print", 5, 10 }, { "<\x01", "module_news --print", 30, 11 },