mirror of
https://github.com/vale981/spectrwm
synced 2025-03-04 17:31:40 -05:00
Add new option: iconic_enabled
When one or more windows are iconic, show the count in bar. Add new bar_format character sequence: +M Replaced with iconic window count. Closes #19
This commit is contained in:
parent
2bf2ca8bf0
commit
75649b6a4b
3 changed files with 32 additions and 1 deletions
|
@ -174,6 +174,7 @@ It may contain the following character sequences:
|
|||
.It Li "+D" Ta "Workspace name"
|
||||
.It Li "+F" Ta "Floating indicator"
|
||||
.It Li "+I" Ta "Workspace index"
|
||||
.It Li "+M" Ta "Number of iconic (minimized) windows in workspace"
|
||||
.It Li "+N" Ta "Screen number"
|
||||
.It Li "+P" Ta "Window class and instance separated by a colon"
|
||||
.It Li "+S" Ta "Stacking algorithm"
|
||||
|
@ -221,6 +222,9 @@ Disable by setting to 0
|
|||
so a custom clock could be used in the
|
||||
.Pa bar_action
|
||||
script.
|
||||
.It Ic iconic_enabled
|
||||
Display the number of iconic (minimized) windows in the status bar.
|
||||
Enable by setting to 1.
|
||||
.It Ic color_focus
|
||||
Border color of the currently focussed window.
|
||||
.It Ic color_unfocus
|
||||
|
|
28
spectrwm.c
28
spectrwm.c
|
@ -373,6 +373,7 @@ int bar_justify = SWM_BAR_JUSTIFY_LEFT;
|
|||
char *bar_format = NULL;
|
||||
int stack_enabled = 1;
|
||||
int clock_enabled = 1;
|
||||
int iconic_enabled = 0;
|
||||
int urgent_enabled = 0;
|
||||
char *clock_format = NULL;
|
||||
int window_class_enabled = 0;
|
||||
|
@ -2077,6 +2078,8 @@ bar_workspace_name(char *s, size_t sz, struct swm_region *r)
|
|||
void
|
||||
bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz)
|
||||
{
|
||||
struct ws_win *w;
|
||||
|
||||
/* if format provided, just copy the buffers */
|
||||
if (bar_format != NULL) {
|
||||
strlcpy(fmtnew, fmtexp, sz);
|
||||
|
@ -2094,6 +2097,15 @@ bar_fmt(const char *fmtexp, char *fmtnew, struct swm_region *r, size_t sz)
|
|||
/* only show the workspace name if there's actually one */
|
||||
if (r != NULL && r->ws != NULL && r->ws->name != NULL)
|
||||
strlcat(fmtnew, "<+D>", sz);
|
||||
|
||||
/* If enabled, only show the iconic count if there are iconic wins. */
|
||||
if (iconic_enabled && r != NULL && r->ws != NULL)
|
||||
TAILQ_FOREACH(w, &r->ws->winlist, entry)
|
||||
if (w->iconic) {
|
||||
strlcat(fmtnew, "{+M}", sz);
|
||||
break;
|
||||
}
|
||||
|
||||
strlcat(fmtnew, "+3<", sz);
|
||||
|
||||
if (clock_enabled) {
|
||||
|
@ -2143,9 +2155,10 @@ char *
|
|||
bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep,
|
||||
size_t sz)
|
||||
{
|
||||
struct ws_win *w;
|
||||
char *ptr;
|
||||
char tmp[SWM_BAR_MAX];
|
||||
int limit, size;
|
||||
int limit, size, count;
|
||||
size_t len;
|
||||
|
||||
/* reset strlcat(3) buffer */
|
||||
|
@ -2183,6 +2196,14 @@ bar_replace_seq(char *fmt, char *fmtrep, struct swm_region *r, size_t *offrep,
|
|||
case 'I':
|
||||
snprintf(tmp, sizeof tmp, "%d", r->ws->idx + 1);
|
||||
break;
|
||||
case 'M':
|
||||
count = 0;
|
||||
TAILQ_FOREACH(w, &r->ws->winlist, entry)
|
||||
if (w->iconic)
|
||||
++count;
|
||||
|
||||
snprintf(tmp, sizeof tmp, "%d", count);
|
||||
break;
|
||||
case 'N':
|
||||
snprintf(tmp, sizeof tmp, "%d", r->s->idx + 1);
|
||||
break;
|
||||
|
@ -7179,6 +7200,7 @@ enum {
|
|||
SWM_S_FOCUS_CLOSE_WRAP,
|
||||
SWM_S_FOCUS_DEFAULT,
|
||||
SWM_S_FOCUS_MODE,
|
||||
SWM_S_ICONIC_ENABLED,
|
||||
SWM_S_REGION_PADDING,
|
||||
SWM_S_SPAWN_ORDER,
|
||||
SWM_S_SPAWN_TERM,
|
||||
|
@ -7346,6 +7368,9 @@ setconfvalue(const char *selector, const char *value, int flags)
|
|||
else
|
||||
errx(1, "focus_mode");
|
||||
break;
|
||||
case SWM_S_ICONIC_ENABLED:
|
||||
iconic_enabled = atoi(value);
|
||||
break;
|
||||
case SWM_S_REGION_PADDING:
|
||||
region_padding = atoi(value);
|
||||
if (region_padding < 0)
|
||||
|
@ -7649,6 +7674,7 @@ struct config_option configopt[] = {
|
|||
{ "focus_close_wrap", setconfvalue, SWM_S_FOCUS_CLOSE_WRAP },
|
||||
{ "focus_default", setconfvalue, SWM_S_FOCUS_DEFAULT },
|
||||
{ "focus_mode", setconfvalue, SWM_S_FOCUS_MODE },
|
||||
{ "iconic_enabled", setconfvalue, SWM_S_ICONIC_ENABLED },
|
||||
{ "keyboard_mapping", setkeymapping, 0 },
|
||||
{ "layout", setlayout, 0 },
|
||||
{ "modkey", setconfmodkey, 0 },
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
# stack_enabled = 1
|
||||
# clock_enabled = 1
|
||||
# clock_format = %a %b %d %R %Z %Y
|
||||
# iconic_enabled = 0
|
||||
# window_class_enabled = 0
|
||||
# window_instance_enabled = 0
|
||||
# window_name_enabled = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue