+ int sid, i, num_screens;
+
+ sid = (selector == NULL || strlen(selector) == 0) ? -1 : atoi(selector);
+
+ /*
+ * When setting focus/unfocus colors, we need to also
+ * set maximize colors to match if they haven't been customized.
+ */
+ i = sid < 0 ? 0 : sid;
+ if (flags == SWM_S_COLOR_FOCUS &&
+ !screens[i].c[SWM_S_COLOR_FOCUS_MAXIMIZED].manual)
+ setscreencolor(value, sid, SWM_S_COLOR_FOCUS_MAXIMIZED);
+ else if (flags == SWM_S_COLOR_UNFOCUS &&
+ !screens[i].c[SWM_S_COLOR_UNFOCUS_MAXIMIZED].manual)
+ setscreencolor(value, sid, SWM_S_COLOR_UNFOCUS_MAXIMIZED);
+
+ setscreencolor(value, sid, flags);
+
+ /* Track override of color. */
+ num_screens = get_screen_count();
+ if (sid > 0 && sid <= num_screens) {
+ screens[i].c[flags].manual = 1;
+ } else if (sid == -1) {
+ for (i = 0; i < num_screens; ++i)
+ screens[i].c[flags].manual = 1;
+ } else {
+ errx(1, "invalid screen index: %d out of bounds (maximum %d)",
+ sid, num_screens);
+ }
+