.Aq arg
is zero or more arguments to the program.
.Pp
-The following variables represent settable values in
-.Nm
-(see the
-.Sx CONFIGURATION FILES
-section above),
-and may be used in the
-.Aq arg
-fields and will be substituted for values at the time the program is spawned:
+The following argument variables will be substituted for values at the time the program
+is spawned:
.Pp
.Bl -tag -width "$bar_font_color" -offset indent -compact
.It Cm $bar_border
.It Cm $bar_font_color
.It Cm $color_focus
.It Cm $color_unfocus
+.It Cm $region_index
+.It Cm $workspace_index
.El
.Pp
Example:
#endif
struct ws_win *get_pointer_win(xcb_window_t);
struct ws_win *get_region_focus(struct swm_region *);
+int get_region_index(struct swm_region *);
xcb_screen_t *get_screen(int);
#ifdef SWM_DEBUG
char *get_stack_mode_name(uint8_t);
return (NULL);
}
+int
+get_region_index(struct swm_region *r)
+{
+ struct swm_region *rr;
+ int ridx = 0;
+
+ if (r == NULL)
+ return -1;
+
+ TAILQ_FOREACH(rr, &r->s->rl, entry) {
+ if (rr == r)
+ break;
+ ++ridx;
+ }
+
+ if (rr == NULL)
+ return -1;
+
+ return ridx;
+}
+
void
focus_flush(void)
{
strdup(r->s->c[SWM_S_COLOR_UNFOCUS].name))
== NULL)
err(1, "spawn_custom color unfocus");
+ } else if (!strcasecmp(ap, "$region_index")) {
+ if (asprintf(&real_args[i], "%d",
+ get_region_index(r) + 1) < 1)
+ err(1, "spawn_custom region index");
+ } else if (!strcasecmp(ap, "$workspace_index")) {
+ if (asprintf(&real_args[i], "%d", r->ws->idx + 1) < 1)
+ err(1, "spawn_custom workspace index");
} else {
/* no match --> copy as is */
if ((real_args[i] = strdup(ap)) == NULL)