- config.client.focused.border = get_colorpixel(conn, "#4c7899");
- config.client.focused.background = get_colorpixel(conn, "#285577");
- config.client.focused.text = get_colorpixel(conn, "#ffffff");
-
- config.client.focused_inactive.border = get_colorpixel(conn, "#4c7899");
- config.client.focused_inactive.background = get_colorpixel(conn, "#555555");
- config.client.focused_inactive.text = get_colorpixel(conn, "#ffffff");
-
- config.client.unfocused.border = get_colorpixel(conn, "#333333");
- config.client.unfocused.background = get_colorpixel(conn, "#222222");
- config.client.unfocused.text = get_colorpixel(conn, "#888888");
-
- config.bar.focused.border = get_colorpixel(conn, "#4c7899");
- config.bar.focused.background = get_colorpixel(conn, "#285577");
- config.bar.focused.text = get_colorpixel(conn, "#ffffff");
-
- config.bar.unfocused.border = get_colorpixel(conn, "#333333");
- config.bar.unfocused.background = get_colorpixel(conn, "#222222");
- config.bar.unfocused.text = get_colorpixel(conn, "#888888");
-
- FILE *handle;
- if (override_configpath != NULL) {
- if ((handle = fopen(override_configpath, "r")) == NULL)
- die("Could not open configfile \"%s\".\n", override_configpath);
- } else {
- /* We first check for ~/.i3/config, then for /etc/i3/config */
- char *globbed = glob_path("~/.i3/config");
- if ((handle = fopen(globbed, "r")) == NULL)
- if ((handle = fopen("/etc/i3/config", "r")) == NULL)
- die("Neither \"%s\" nor /etc/i3/config could be opened\n", globbed);
- free(globbed);
- }
- char key[512], value[512], buffer[1026];
-
- while (!feof(handle)) {
- if (fgets(buffer, 1024, handle) == NULL) {
- /* fgets returns NULL on EOF and on error, so see which one it is. */
- if (feof(handle))
- break;
- die("Could not read configuration file\n");
- }
-
- if (config.terminal != NULL)
- replace_variable(buffer, "$terminal", config.terminal);
-
- /* Replace all custom variables */
- struct Variable *current;
- SLIST_FOREACH(current, &variables, variables)
- replace_variable(buffer, current->key, current->value);
-
- /* sscanf implicitly strips whitespace. Also, we skip comments and empty lines. */
- if (sscanf(buffer, "%s %[^\n]", key, value) < 1 ||
- key[0] == '#' || strlen(key) < 3)
- continue;
-
- OPTION_STRING(terminal);
- OPTION_STRING(font);
-
- /* Colors */
- OPTION_COLORTRIPLE("client.focused", client.focused);
- OPTION_COLORTRIPLE("client.focused_inactive", client.focused_inactive);
- OPTION_COLORTRIPLE("client.unfocused", client.unfocused);
- OPTION_COLORTRIPLE("bar.focused", bar.focused);
- OPTION_COLORTRIPLE("bar.unfocused", bar.unfocused);
-
- /* exec-lines (autostart) */
- if (strcasecmp(key, "exec") == 0) {
- struct Autostart *new = smalloc(sizeof(struct Autostart));
- new->command = sstrdup(value);
- TAILQ_INSERT_TAIL(&autostarts, new, autostarts);
- continue;
- }
-
- /* key bindings */
- if (strcasecmp(key, "bind") == 0 || strcasecmp(key, "bindsym") == 0) {
- #define CHECK_MODIFIER(name) \
- if (strncasecmp(walk, #name, strlen(#name)) == 0) { \
- modifiers |= BIND_##name; \
- walk += strlen(#name) + 1; \
- continue; \
- }
- char *walk = value, *rest;
- uint32_t modifiers = 0;
-
- while (*walk != '\0') {
- /* Need to check for Mod1-5, Ctrl, Shift, Mode_switch */
- CHECK_MODIFIER(SHIFT);
- CHECK_MODIFIER(CONTROL);
- CHECK_MODIFIER(MODE_SWITCH);
- CHECK_MODIFIER(MOD1);
- CHECK_MODIFIER(MOD2);
- CHECK_MODIFIER(MOD3);
- CHECK_MODIFIER(MOD4);
- CHECK_MODIFIER(MOD5);
-
- /* No modifier found? Then we’re done with this step */
- break;
- }
-
- Binding *new = scalloc(sizeof(Binding));
-
- /* Now check for the keycode or copy the symbol */
- if (strcasecmp(key, "bind") == 0) {
- int keycode = strtol(walk, &rest, 10);
- if (!rest || *rest != ' ')
- die("Invalid binding (keycode)\n");
- new->keycode = keycode;
- } else {
- rest = walk;
- char *sym = rest;
- while (*rest != '\0' && *rest != ' ')
- rest++;
- if (*rest != ' ')
- die("Invalid binding (keysym)\n");
- new->symbol = strndup(sym, (rest - sym));
- }
- rest++;
- LOG("keycode = %d, symbol = %s, modifiers = %d, command = *%s*\n", new->keycode, new->symbol, modifiers, rest);
- new->mods = modifiers;
- new->command = sstrdup(rest);
- TAILQ_INSERT_TAIL(&bindings, new, bindings);
- continue;
- }
-
- if (strcasecmp(key, "floating_modifier") == 0) {
- char *walk = value;
- uint32_t modifiers = 0;
-
- while (*walk != '\0') {
- /* Need to check for Mod1-5, Ctrl, Shift, Mode_switch */
- CHECK_MODIFIER(SHIFT);
- CHECK_MODIFIER(CONTROL);
- CHECK_MODIFIER(MODE_SWITCH);
- CHECK_MODIFIER(MOD1);
- CHECK_MODIFIER(MOD2);
- CHECK_MODIFIER(MOD3);
- CHECK_MODIFIER(MOD4);
- CHECK_MODIFIER(MOD5);
-
- /* No modifier found? Then we’re done with this step */
- break;
- }
-
- LOG("Floating modifiers = %d\n", modifiers);
- config.floating_modifier = modifiers;
- continue;
- }
-
- /* name "workspace number" "name of the workspace" */
- if (strcasecmp(key, "name") == 0) {
- LOG("name workspace: %s\n",value);
- char *ws_str = sstrdup(value);
- char *end = strchr(ws_str, ' ');
- if (end == NULL)
- die("Malformed name, couln't find terminating space\n");
- *end = '\0';
-
- /* Strip trailing whitespace */
- while (strlen(value) > 0 && value[strlen(value)-1] == ' ')
- value[strlen(value)-1] = '\0';
-
- int ws_num = atoi(ws_str);
+#define INIT_COLOR(x, cborder, cbackground, ctext) \
+ do { \
+ x.border = get_colorpixel(cborder); \
+ x.background = get_colorpixel(cbackground); \
+ x.text = get_colorpixel(ctext); \
+ } while (0)
+
+ config.client.background = get_colorpixel("#000000");
+ INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff");
+ INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff");
+ INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888");
+ INIT_COLOR(config.client.urgent, "#2f343a", "#900000", "#ffffff");
+ INIT_COLOR(config.bar.focused, "#4c7899", "#285577", "#ffffff");
+ INIT_COLOR(config.bar.unfocused, "#333333", "#222222", "#888888");
+ INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff");
+
+ config.default_border = BS_NORMAL;
+ /* Set default_orientation to NO_ORIENTATION for auto orientation. */
+ config.default_orientation = NO_ORIENTATION;
+
+ parse_configuration(override_configpath);