hide empty modules

This commit is contained in:
speedie 2022-12-05 21:56:12 +01:00
parent ca564d88a0
commit 63c96d1bd4
3 changed files with 15 additions and 8 deletions

View file

@ -60,7 +60,7 @@ static int automove = 1; /* Allow clients to automatic
static int autoresize = 1; /* Allow resizing clients automatically when they request it. */
/* Font options */
static char font[] = "Noto Sans Regular 9"; /* Font to draw the bar with */
static char font[] = "Noto Sans Regular 7"; /* Font to draw the bar with */
/* Status options */
static char defaultstatus[] = ""; /* What to print when a status bar is not running */

View file

@ -87,15 +87,21 @@ getcmd(const Module *module, char *output)
} while (!s && e == EINTR);
pclose(cmdf);
int i = strlen(module->icon);
strcpy(output, module->icon);
if (s && hideemptymodule)
strcpy(output, module->icon);
else if (!hideemptymodule)
strcpy(output, module->icon);
strcpy(output+i, tmpstr);
remove_all(output, '\n');
i = strlen(output);
remove_all(output, '\n');
i = strlen(output);
if ((i > 0 && module != &modules[LENGTH(modules) - 1])){
strcat(output, separator);
}
i+=strlen(separator);
output[i++] = '\0';
output[i++] = '\0';
}
static void

View file

@ -27,6 +27,7 @@ static const Module modules[] = {
{ "<\x01", "module_news --print", 30, 11 },
};
static char leftpadding[] = ""; /* Padding on the left side of the status text */
static char rightpadding[] = ""; /* Padding on the right side of the status text */
static char *separator = ""; /* Delimiter between modules. Note that this will be applied even if a command is empty. */
static int hideemptymodule = 1; /* Hide the module if command returns nothing */
static char leftpadding[] = ""; /* Padding on the left side of the status text */
static char rightpadding[] = ""; /* Padding on the right side of the status text */
static char *separator = ""; /* Delimiter between modules. Note that this will be applied even if a command is empty. */