From 4f08514872203bb6297d6f076a7b0aacd73a79c2 Mon Sep 17 00:00:00 2001 From: Reginald Kennedy Date: Thu, 6 Sep 2012 20:16:14 +0800 Subject: [PATCH] Add new bar_enabled_ws[x] config option. It is now possible to set the default state for bar_toggle_ws. --- spectrwm.1 | 10 +++++++++- spectrwm.c | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/spectrwm.1 b/spectrwm.1 index 3ef5233..59a5acb 100644 --- a/spectrwm.1 +++ b/spectrwm.1 @@ -106,7 +106,15 @@ Color of the status bar window in screen Update frequency, in seconds, of external script that populates the status bar. .It Ic bar_enabled -Enable or disable status bar. +Set default +.Ar bar_toggle +state; default is 1. +.It Ic bar_enabled_ws Ns Bq Ar x +Set default +.Ar bar_toggle_ws +state on workspace +.Ar x ; +default is 1. .It Ic bar_font Font used in the status bar. Either Xft or X Logical Font Description (XLFD) may be used to specify fonts. Fallback fonts may be specified by separating diff --git a/spectrwm.c b/spectrwm.c index 1f092e9..639969f 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -6435,6 +6435,7 @@ enum { SWM_S_BAR_BORDER_WIDTH, SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, + SWM_S_BAR_ENABLED_WS, SWM_S_BAR_FONT, SWM_S_BAR_FORMAT, SWM_S_BAR_JUSTIFY, @@ -6466,8 +6467,9 @@ enum { int setconfvalue(char *selector, char *value, int flags) { - int i; - char *b; + struct workspace *ws; + int i, ws_id, num_screens; + char *b; /* suppress unused warning since var is needed */ (void)selector; @@ -6492,6 +6494,18 @@ setconfvalue(char *selector, char *value, int flags) case SWM_S_BAR_ENABLED: bar_enabled = atoi(value); break; + case SWM_S_BAR_ENABLED_WS: + ws_id = atoi(selector) - 1; + if (ws_id < 0 || ws_id >= workspace_limit) + errx(1, "setconfvalue: bar_enabled_ws: invalid " + "workspace %d.", ws_id + 1); + + num_screens = xcb_setup_roots_length(xcb_get_setup(conn)); + for (i = 0; i < num_screens; i++) { + ws = (struct workspace *)&screens[i].ws; + ws[ws_id].bar_enabled = atoi(value); + } + break; case SWM_S_BAR_FONT: b = bar_fonts; if (asprintf(&bar_fonts, "%s,%s", value, bar_fonts) == -1) @@ -6857,6 +6871,7 @@ struct config_option { }; struct config_option configopt[] = { { "bar_enabled", setconfvalue, SWM_S_BAR_ENABLED }, + { "bar_enabled_ws", setconfvalue, SWM_S_BAR_ENABLED_WS }, { "bar_at_bottom", setconfvalue, SWM_S_BAR_AT_BOTTOM }, { "bar_border", setconfcolor, SWM_S_COLOR_BAR_BORDER }, { "bar_border_width", setconfvalue, SWM_S_BAR_BORDER_WIDTH }, -- 1.7.10.4