Exemplo n.º 1
0
Arquivo: config.c Projeto: Engil/wmfs
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);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
Arquivo: config.c Projeto: Engil/wmfs
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);
     }
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
static int fetch_registered_part(struct mailprivacy * privacy,
    int (* fetch_section)(mailmessage *, struct mailmime *,
        char **, size_t *),
    struct mailmime * mime,
    char ** result, size_t * result_len)
{
  mailmessage * dummy_msg;
  int res;
  char * content;
  size_t content_len;
  int r;
  
  dummy_msg = mime_message_init(NULL);
  if (dummy_msg == NULL) {
    res = MAIL_ERROR_MEMORY;
    goto err;
  }
  
  r = mime_message_set_tmpdir(dummy_msg, privacy->tmp_dir);
  if (r != MAIL_NO_ERROR) {
    res = MAIL_ERROR_MEMORY;
    goto free_msg;
  }
  
  r = fetch_section(dummy_msg, mime, &content, &content_len);
  if (r != MAIL_NO_ERROR) {
    res = r;
    goto free_msg;
  }
  
  r = register_result_mmapstr(privacy, content);
  if (r != MAIL_NO_ERROR) {
    res = r;
    goto free_fetch;
  }
  
  mailmessage_free(dummy_msg);
  
  * result = content;
  * result_len = content_len;
  
  return MAIL_NO_ERROR;
  
 free_fetch:
  mailmessage_fetch_result_free(dummy_msg, content);
 free_msg:
  mailmessage_free(dummy_msg);
 err:
  return res;
}
Exemplo n.º 7
0
Arquivo: config.c Projeto: HFT/HFTIrc
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);
          }
     }
}
Exemplo n.º 8
0
static void
config_rule(void)
{
     int i, n;
     struct conf_sec *sec, **ks;
     struct rule *r;
     char *tn, *tmp;

     /* [rules] */
     sec = fetch_section_first(NULL, "rules");
     ks = fetch_section(sec, "rule");
     n = fetch_section_count(ks);

     SLIST_INIT(&W->h.rule);

     /* [rule] */
     for(i = 0; i < n; ++i)
     {
          r = (struct rule*)xcalloc(1, sizeof(struct rule));

          ISTRDUP(r->class,          fetch_opt_first(ks[i], "", "class").str);
          ISTRDUP(r->instance,       fetch_opt_first(ks[i], "", "instance").str);
          ISTRDUP(r->role,           fetch_opt_first(ks[i], "", "role").str);
          ISTRDUP(r->name ,          fetch_opt_first(ks[i], "", "name").str);
          ISTRDUP(r->client_machine, fetch_opt_first(ks[i], "", "client_machine").str);

          r->screen   = fetch_opt_first(ks[i], "-1", "screen").num;
          r->tag      = fetch_opt_first(ks[i], "-1", "tag").num;

          FLAGAPPLY(r->flags, fetch_opt_first(ks[i], "false", "free").boolean,       RULE_FREE);
          FLAGAPPLY(r->flags, fetch_opt_first(ks[i], "false", "tab").boolean,        RULE_TAB);
          FLAGAPPLY(r->flags, fetch_opt_first(ks[i], "false", "ignore_tag").boolean, RULE_IGNORE_TAG);

          if((tn = fetch_opt_first(ks[i], "", "theme").str))
               r->theme = name_to_theme(tn);
          else
               r->theme = W->ctheme;

          SLIST_INSERT_HEAD(&W->h.rule, r, next);
     }

     free(ks);
}
Exemplo n.º 9
0
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);
     }
}
Exemplo n.º 10
0
Arquivo: config.c Projeto: n4cht/kwm
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;
     }
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
static int fetch(mailmessage * msg_info,
    char ** result, size_t * result_len)
{
  return fetch_section(msg_info, msg_info->msg_mime, result, result_len);
}