See the issue #3163 (https://github.com/i3/i3/issues/3163).
Add strip_workspace_name to strip off the workspace name.
}
------------------------
-=== Strip workspace numbers
+=== Strip workspace numbers/name
Specifies whether workspace numbers should be displayed within the workspace
buttons. This is useful if you want to have a named workspace that stays in
instance, to display Roman numerals rather than digits by naming your
workspaces to "1:I", "2:II", "3:III", "4:IV", ...
+When +strip_workspace_name+ is set to +yes+, any workspace that has a name of
+the form "[n]:[NAME]" will display only the number.
+
The default is to display the full name within the workspace button.
*Syntax*:
------------------------------
strip_workspace_numbers yes|no
+strip_workspace_name yes|no
------------------------------
*Example*:
bool disable_binding_mode_indicator;
bool disable_ws;
bool strip_ws_numbers;
+ bool strip_ws_name;
char *bar_id;
char *command;
char *fontname;
return 1;
}
+ if (!strcmp(cur_key, "strip_workspace_name")) {
+ DLOG("strip_workspace_name = %d\n", val);
+ config.strip_ws_name = val;
+ return 1;
+ }
+
if (!strcmp(cur_key, "verbose")) {
DLOG("verbose = %d\n", val);
config.verbose = val;
const char *ws_name = (const char *)val;
params->workspaces_walk->canonical_name = sstrndup(ws_name, len);
- if (config.strip_ws_numbers && params->workspaces_walk->num >= 0) {
- /* Special case: strip off the workspace number */
+ if ((config.strip_ws_numbers || config.strip_ws_name) && params->workspaces_walk->num >= 0) {
+ /* Special case: strip off the workspace number/name */
static char ws_num[10];
snprintf(ws_num, sizeof(ws_num), "%d", params->workspaces_walk->num);
if (offset && ws_name[offset] == ':')
offset += 1;
- /* Offset may be equal to length, in which case display the number */
- params->workspaces_walk->name = (offset < len
- ? i3string_from_markup_with_length(ws_name + offset, len - offset)
- : i3string_from_markup(ws_num));
-
+ if (config.strip_ws_numbers) {
+ /* Offset may be equal to length, in which case display the number */
+ params->workspaces_walk->name = (offset < len
+ ? i3string_from_markup_with_length(ws_name + offset, len - offset)
+ : i3string_from_markup(ws_num));
+ } else {
+ params->workspaces_walk->name = i3string_from_markup(ws_num);
+ }
} else {
/* Default case: just save the name */
params->workspaces_walk->name = i3string_from_markup_with_length(ws_name, len);
CFGFUN(bar_binding_mode_indicator, const char *value);
CFGFUN(bar_workspace_buttons, const char *value);
CFGFUN(bar_strip_workspace_numbers, const char *value);
+CFGFUN(bar_strip_workspace_name, const char *value);
CFGFUN(bar_start);
CFGFUN(bar_finish);
* 'strip_workspace_numbers yes'. */
bool strip_workspace_numbers;
+ /** Strip workspace name? Configuration option is
+ * 'strip_workspace_name yes'. */
+ bool strip_workspace_name;
+
/** Hide mode button? Configuration option is 'binding_mode_indicator no'
* but we invert the bool for the same reason as hide_workspace_buttons.*/
bool hide_binding_mode_indicator;
'binding_mode_indicator' -> BAR_BINDING_MODE_INDICATOR
'workspace_buttons' -> BAR_WORKSPACE_BUTTONS
'strip_workspace_numbers' -> BAR_STRIP_WORKSPACE_NUMBERS
+ 'strip_workspace_name' -> BAR_STRIP_WORKSPACE_NAME
'verbose' -> BAR_VERBOSE
'colors' -> BAR_COLORS_BRACE
'}'
value = word
-> call cfg_bar_strip_workspace_numbers($value); BAR
+state BAR_STRIP_WORKSPACE_NAME:
+ value = word
+ -> call cfg_bar_strip_workspace_name($value); BAR
+
state BAR_VERBOSE:
value = word
-> call cfg_bar_verbose($value); BAR
current_bar->strip_workspace_numbers = eval_boolstr(value);
}
+CFGFUN(bar_strip_workspace_name, const char *value) {
+ current_bar->strip_workspace_name = eval_boolstr(value);
+}
+
CFGFUN(bar_start) {
current_bar = scalloc(1, sizeof(struct Barconfig));
TAILQ_INIT(&(current_bar->bar_bindings));
ystr("strip_workspace_numbers");
y(bool, config->strip_workspace_numbers);
+ ystr("strip_workspace_name");
+ y(bool, config->strip_workspace_name);
+
ystr("binding_mode_indicator");
y(bool, !config->hide_binding_mode_indicator);
$expected = <<'EOT';
cfg_bar_start()
cfg_bar_output(LVDS-1)
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'hidden_state', 'id', 'modifier', 'wheel_up_cmd', 'wheel_down_cmd', 'bindsym', 'position', 'output', 'tray_output', 'tray_padding', 'font', 'separator_symbol', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
+ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'hidden_state', 'id', 'modifier', 'wheel_up_cmd', 'wheel_down_cmd', 'bindsym', 'position', 'output', 'tray_output', 'tray_padding', 'font', 'separator_symbol', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'strip_workspace_name', 'verbose', 'colors', '}'
ERROR: CONFIG: (in file <stdin>)
ERROR: CONFIG: Line 1: bar {
ERROR: CONFIG: Line 2: output LVDS-1