static void config_bars(void) { struct screen *s; struct theme *t; size_t i, n; struct conf_sec *sec, **ks; int screenid; char *name, *elem; enum barpos pos = BarTop; /* [bars] */ sec = fetch_section_first(NULL, "bars"); ks = fetch_section(sec, "bar"); n = fetch_section_count(ks); /* [bar] */ for(i = 0; i < n; ++i) { name = fetch_opt_first(ks[i], "default", "name").str; elem = fetch_opt_first(ks[i], "", "elements").str; screenid = fetch_opt_first(ks[i], "-1", "screen").num; t = name_to_theme(fetch_opt_first(ks[i], "default", "theme").str); pos = fetch_opt_first(ks[i], "0", "position").num; SLIST_FOREACH(s, &W->h.screen, next) if(screenid == s->id || screenid == -1) infobar_new(s, name, t, pos, elem); } free(ks); }
static void config_launcher(void) { struct conf_sec *sec, **ks; struct launcher *l; int n, i; /* [launchers] */ sec = fetch_section_first(NULL, "launchers"); ks = fetch_section(sec, "launcher"); n = fetch_section_count(ks); SLIST_INIT(&W->h.launcher); /* [launcher] */ for(i = 0; i < n; ++i) { l = xcalloc(1, sizeof(struct launcher)); l->name = xstrdup(fetch_opt_first(ks[i], "default", "name").str); l->prompt = xstrdup(fetch_opt_first(ks[i], ":", "prompt").str); l->command = xstrdup(fetch_opt_first(ks[i], "spawn", "command").str); if((l->width = fetch_opt_first(ks[i], "150", "width").num) <= 0) l->width = 150; SLIST_INSERT_HEAD(&W->h.launcher, l, next); } free(ks); }
static void config_mouse_section(struct mbhead *mousebinds, struct conf_sec **sec) { struct mousebind *m; int i = 0; char *p; SLIST_INIT(mousebinds); for(; sec[i]; ++i) { m = xcalloc(1, sizeof(struct mousebind)); m->button = fetch_opt_first(sec[i], "1", "button").num; m->func = uicb_name_func(fetch_opt_first(sec[i], "", "func").str); if((p = fetch_opt_first(sec[i], "", "cmd").str)) m->cmd = xstrdup(p); m->use_area = false; SLIST_INSERT_HEAD(mousebinds, m, next); SLIST_INSERT_HEAD(&W->h.mousebind, m, globnext); } }
static void config_client(void) { struct conf_sec *sec, **mb; char *tmp; /* [client] */ sec = fetch_section_first(NULL, "client"); W->padding = fetch_opt_first(sec, "0", "padding").num; W->client_mod = modkey_keysym(fetch_opt_first(sec, "Super", "key_modifier").str); if(fetch_opt_first(sec, "0", "autofocus").boolean) W->flags |= WMFS_AUTOFOCUS; /* Get theme */ tmp = fetch_opt_first(sec, "default", "theme").str; W->ctheme = name_to_theme(tmp); /* Get focus configuration */ W->cfocus = 0; tmp = fetch_opt_first(sec, "enter", "focus").str; if(strstr(tmp, "enter")) W->cfocus |= CFOCUS_ENTER; if(strstr(tmp, "click")) W->cfocus |= CFOCUS_CLICK; /* [mouse] */ /* for client frame AND titlebar */ if((mb = fetch_section(sec, "mouse"))) { config_mouse_section(&W->tmp_head.client, mb); free(mb); } }
static void config_misc(void) { struct conf_sec *misc; misc = fetch_section_first(NULL, "misc"); SSTRCPY(hftirc.conf.datef, fetch_opt_first(misc, "%m-%d %H:%M:%S", "date_format").str); hftirc.conf.bell = fetch_opt_first(misc, "false", "bell").boolean; hftirc.conf.nicklist = fetch_opt_first(misc, "false", "nicklist_enable").boolean; hftirc.conf.lastlinepos = fetch_opt_first(misc, "false", "lastline_position").boolean; }
static void config_keybind(void) { int i, n; size_t j; struct conf_sec *sec, **ks; struct opt_type *opt; char *cmd; struct keybind *k; /* [keys] */ sec = fetch_section_first(NULL, "keys"); ks = fetch_section(sec, "key"); n = fetch_section_count(ks); SLIST_INIT(&W->h.keybind); /* [key] */ for(i = 0; i < n; ++i) { k = (struct keybind*)xcalloc(1, sizeof(struct keybind)); /* mod = {} */ opt = fetch_opt(ks[i], "", "mod"); for(j = k->mod = 0; j < fetch_opt_count(opt); ++j) k->mod |= modkey_keysym(opt[j].str); free(opt); /* key = */ k->keysym = XStringToKeysym(fetch_opt_first(ks[i], "None", "key").str); /* func = */ if(!(k->func = uicb_name_func(fetch_opt_first(ks[i], "", "func").str))) { warnxl("configuration: Unknown Function \"%s\".", fetch_opt_first(ks[i], "", "func").str); k->func = uicb_spawn; } /* cmd = */ if((cmd = fetch_opt_first(ks[i], "", "cmd").str)) k->cmd = xstrdup(cmd); SLIST_INSERT_HEAD(&W->h.keybind, k, next); } wmfs_grab_keys(); free(ks); }
static void config_ui(void) { struct conf_sec *ui, *colors; ui = fetch_section_first(NULL, "ui"); hftirc.conf.nickcolor = fetch_opt_first(ui, "false", "nick_color_enable").boolean; /* Colors section */ colors = fetch_section_first(ui, "colors"); hftirc.conf.tcolor = color_to_id(fetch_opt_first(colors, "blue", "color_theme").str); }
static void config_tag(void) { struct screen *s; struct tag *t; size_t i, n; struct conf_sec *sec, **ks, **mb; char *name, *tmp; int screenid; /* [tags] */ sec = fetch_section_first(NULL, "tags"); ks = fetch_section(sec, "tag"); n = fetch_section_count(ks); if (fetch_opt_first(sec, "1", "circular").boolean) W->flags |= WMFS_TAGCIRC; /* [mouse] */ if((mb = fetch_section(sec, "mouse"))) { config_mouse_section(&W->tmp_head.tag, mb); free(mb); } /* [tag] */ for(i = 0; i < n; ++i) { name = fetch_opt_first(ks[i], "tag", "name").str; screenid = fetch_opt_first(ks[i], "-1", "screen").num; SLIST_FOREACH(s, &W->h.screen, next) if(screenid == s->id || screenid == -1) { t = tag_new(s, name); t->statusctx = status_new_ctx(NULL, NULL); ISTRDUP(t->statusctx.status, fetch_opt_first(ks[i], "", "statusline").str); if(t->statusctx.status) status_parse(&t->statusctx); } } /* If no tag at all on a screen, add one anyway */ SLIST_FOREACH(s, &W->h.screen, next) if(TAILQ_EMPTY(&s->tags)) tag_new(s, "tag"); free(ks); }
static void mouse_section(MouseBinding mb[], struct conf_sec **sec) { int n; for (n = 0; sec[n]; n++) { mb[n].tag = fetch_opt_first(sec[n], "-1", "tag").num; mb[n].screen = fetch_opt_first(sec[n], "-1", "screen").num; mb[n].button = char_to_button(fetch_opt_first(sec[n], "1", "button").str, mouse_button_list); mb[n].func = name_to_func(fetch_opt_first(sec[n], "", "func").str, func_list); mb[n].cmd = fetch_opt_first(sec[n], "", "cmd").str; } }
static void config_client(void) { struct conf_sec *sec, **mb; char *tmp; /* [client] */ sec = fetch_section_first(NULL, "client"); W->client_mod = modkey_keysym(fetch_opt_first(sec, "Super", "key_modifier").str); tmp = fetch_opt_first(sec, "default", "theme").str; W->ctheme = name_to_theme(tmp); /* [mouse] */ /* for client frame AND titlebar */ if((mb = fetch_section(sec, "mouse"))) { config_mouse_section(&W->tmp_head.client, mb); free(mb); } }
static void config_ignore(void) { int i = -1; struct conf_sec *ignore; hftirc.conf.ignore = 0; if((ignore = fetch_section_first(NULL, "ignore"))) while(ignorebli[i++].f) if(fetch_opt_first(ignore, "false", (char *)ignorebli[i].name).boolean) hftirc.conf.ignore |= ignorebli[i].f; }
static void config_server(void) { int i, j, n = 0; struct conf_sec **serv; struct opt_type *opt; ServInfo defsi = { "Hft", "irc.freenode.net", "", 6667, "hftircuser", " ", "HFTIrcuser", "HFTIrcuser"}; if(!(serv = fetch_section(fetch_section_first(NULL, "servers"), "server")) || !(hftirc.conf.nserv = fetch_section_count(serv))) { hftirc.conf.serv = malloc(sizeof(ServInfo)); hftirc.conf.serv[0] = defsi; hftirc.conf.nserv = 1; return; } hftirc.conf.serv = malloc(sizeof(ServInfo) * hftirc.conf.nserv); for(i = 0; i < hftirc.conf.nserv; ++i) { SSTRCPY(hftirc.conf.serv[i].adress, fetch_opt_first(serv[i], "irc.hft-community.org", "adress").str); SSTRCPY(hftirc.conf.serv[i].name, fetch_opt_first(serv[i], hftirc.conf.serv[i].adress, "name").str); SSTRCPY(hftirc.conf.serv[i].password, fetch_opt_first(serv[i], "", "password").str); SSTRCPY(hftirc.conf.serv[i].nick, fetch_opt_first(serv[i], "hftircuser", "nickname").str); SSTRCPY(hftirc.conf.serv[i].username, fetch_opt_first(serv[i], "hftircuser", "username").str); SSTRCPY(hftirc.conf.serv[i].realname, fetch_opt_first(serv[i], "hftircuser", "realname").str); hftirc.conf.serv[i].port = fetch_opt_first(serv[i], "6667", "port").num; hftirc.conf.serv[i].ipv6 = fetch_opt_first(serv[i], "false", "ipv6").boolean; opt = fetch_opt(serv[i], "", "channel_autojoin"); if((n = fetch_opt_count(opt))) { if((hftirc.conf.serv[i].nautojoin = n) > 127) ui_print_buf(0, "HFTIrc configuration: section serv (%d), too many channel_autojoin (%d).", i, n); else for(j = 0; j < n; ++j) SSTRCPY(hftirc.conf.serv[i].autojoin[j], opt[j].str); } } }
static void conf_misc_section(void) { int pad = 12; uint opacity = 255; struct conf_sec *sec; sec = fetch_section_first(NULL, "misc"); conf.font = fetch_opt_first(sec, "sans-9", "font").str; conf.raisefocus = fetch_opt_first(sec, "false", "raisefocus").bool; conf.focus_fmouse = fetch_opt_first(sec, "true", "focus_follow_mouse").bool; conf.focus_fmov = fetch_opt_first(sec, "false", "focus_follow_movement").bool; conf.focus_pclick = fetch_opt_first(sec, "true", "focus_pointer_click").bool; conf.status_timing = fetch_opt_first(sec, "1", "status_timing").num; conf.status_path = fetch_opt_first(sec, "", "status_path").str; conf.autostart_path = fetch_opt_first(sec, "", "autostart_path").str; conf.autostart_command = fetch_opt_first(sec, "", "autostart_command").str; pad = fetch_opt_first(sec, "12", "pad").num; opacity = fetch_opt_first(sec, "255", "opacity").num; if(opacity > 255) opacity = 255; conf.opacity = opacity << 24; if(pad > 24 || pad < 1) { warnx("configuration : pad value (%d) incorrect.", pad); pad = 12; } conf.pad = pad; if(conf.status_timing < 0) { warnx("configuration : status_timing value (%d) incorrect.", conf.status_timing); conf.status_timing = 1; } return; }
static void conf_bar_section(void) { struct conf_sec *bar, **mouse, *selbar, *systray; char *barbg; int sc = screen_count(); bar = fetch_section_first(NULL, "bar"); conf.border.bar = fetch_opt_first(bar, "false", "border").bool; conf.bars.height = fetch_opt_first(bar, "-1", "height").num; conf.colors.bar = getcolor((barbg = fetch_opt_first(bar, "#000000", "bg").str)); conf.colors.text = fetch_opt_first(bar, "#ffffff", "fg").str; conf.colors.bar_light_shade = fetch_opt_first(bar, "0.25", "light_shade").fnum; conf.colors.bar_dark_shade = fetch_opt_first(bar, "-0.25", "dark_shade").fnum; mouse = fetch_section(bar, "mouse"); if ((conf.bars.nmouse = fetch_section_count(mouse)) > 0) { conf.bars.mouse = xcalloc(conf.bars.nmouse, sizeof(MouseBinding)); mouse_section(conf.bars.mouse, mouse); } free(mouse); if((systray = fetch_section_first(bar, "systray"))) { conf.systray.active = fetch_opt_first(systray, "true", "active").bool; if((conf.systray.screen = fetch_opt_first(systray, "0", "screen").num) < 0 || conf.systray.screen >= sc) conf.systray.screen = 0; if((conf.systray.spacing = fetch_opt_first(systray, "3", "spacing").num) < 0) conf.systray.spacing = 0; }
static void config_theme(void) { struct theme *t, *p = NULL; size_t i, n; struct conf_sec *sec, **ks; char *tmp; /* [themes] */ sec = fetch_section_first(NULL, "themes"); ks = fetch_section(sec, "theme"); /* No theme section? Make one with default value anyway. */ if(!(n = fetch_section_count(ks))) ++n; SLIST_INIT(&W->h.theme); /* [theme]*/ for(i = 0; i < n; ++i) { t = (struct theme*)xcalloc(1, sizeof(struct theme)); t->name = fetch_opt_first(ks[i], "default", "name").str; wmfs_init_font(fetch_opt_first(ks[i], "fixed", "font").str, t); /* bars */ t->bars.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "bars_fg").str); t->bars.bg = color_atoh(fetch_opt_first(ks[i], "#222222", "bars_bg").str); t->bars_width = fetch_opt_first(ks[i], "12", "bars_width").num; /* * Elements */ t->tags_n.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_normal_fg").str); t->tags_n.bg = color_atoh(fetch_opt_first(ks[i], "#222222", "tags_normal_bg").str); t->tags_s.fg = color_atoh(fetch_opt_first(ks[i], "#222222", "tags_sel_fg").str); t->tags_s.bg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_sel_bg").str); t->tags_o.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_occupied_fg").str); t->tags_o.bg = color_atoh(fetch_opt_first(ks[i], "#444444", "tags_occupied_bg").str); t->tags_u.fg = color_atoh(fetch_opt_first(ks[i], "#444444", "tags_urgent_fg").str); t->tags_u.bg = color_atoh(fetch_opt_first(ks[i], "#CC4444", "tags_urgent_bg").str); t->tags_border_col = color_atoh(fetch_opt_first(ks[i], "#888888", "tags_border_color").str); t->tags_border_width = fetch_opt_first(ks[i], "0", "tags_border_width").num; /* status line */ t->tags_n_sl = status_new_ctx(NULL, t); t->tags_s_sl = status_new_ctx(NULL, t); t->tags_o_sl = status_new_ctx(NULL, t); t->tags_u_sl = status_new_ctx(NULL, t); ISTRDUP(t->tags_n_sl.status, fetch_opt_first(ks[i], "", "tags_normal_statusline").str); ISTRDUP(t->tags_s_sl.status, fetch_opt_first(ks[i], "", "tags_sel_statusline").str); ISTRDUP(t->tags_o_sl.status, fetch_opt_first(ks[i], "", "tags_occupied_statusline").str); ISTRDUP(t->tags_u_sl.status, fetch_opt_first(ks[i], "", "tags_urgent_statusline").str); if(t->tags_n_sl.status) status_parse(&t->tags_n_sl); if(t->tags_s_sl.status) status_parse(&t->tags_s_sl); if(t->tags_o_sl.status) status_parse(&t->tags_o_sl); if(t->tags_u_sl.status) status_parse(&t->tags_u_sl); /* Client / frame */ t->client_n.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "client_normal_fg").str); t->client_n.bg = color_atoh(fetch_opt_first(ks[i], "#222222", "client_normal_bg").str); t->client_s.fg = color_atoh(fetch_opt_first(ks[i], "#222222", "client_sel_fg").str); t->client_s.bg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "client_sel_bg").str); t->frame_bg = color_atoh(fetch_opt_first(ks[i], "#555555", "frame_bg").str); t->client_titlebar_width = fetch_opt_first(ks[i], "12", "client_titlebar_width").num; t->client_border_width = fetch_opt_first(ks[i], "1", "client_border_width").num; /* status line */ t->client_n_sl = status_new_ctx(NULL, t); t->client_s_sl = status_new_ctx(NULL, t); ISTRDUP(t->client_n_sl.status, fetch_opt_first(ks[i], "", "client_normal_statusline").str); ISTRDUP(t->client_s_sl.status, fetch_opt_first(ks[i], "", "client_sel_statusline").str); if(t->client_n_sl.status) status_parse(&t->client_n_sl); if(t->client_s_sl.status) status_parse(&t->client_s_sl); SLIST_INSERT_TAIL(&W->h.theme, t, next, p); p = t; } free(ks); }