switch to libconfuse instead of libconfig

This commit is contained in:
Julien Danjou 2007-10-08 18:45:05 +02:00
parent a3fa2f8d4a
commit de45017b5d
8 changed files with 760 additions and 363 deletions

2
README
View File

@ -5,7 +5,7 @@ It's based on dwm.
Requirements Requirements
------------ ------------
In order to build awesome you need the Xlib header files and libconfig. In order to build awesome you need the Xlib header files and libconfuse.
Installation Installation
------------ ------------

675
awesomerc
View File

@ -1,140 +1,555 @@
# Configuration file for awesome # Configuration file for awesome
awesome: general
{ {
# Default bar position: top, bottom, off border = 1
barpos = "top"; snap = 8
# Window border size resize_hints = true
borderpx = 1; opacity_unfocused = 100
# Window snap pixels focus_move_pointer = false
snap = 8; font = "fixed-12"
# Master window width factor (used by tile layouts) }
mwfact = 0.6;
# Font
font = "fixed-12";
# Tags
tags = ( "1", "2", "3", "4", "5", "6", "7", "8", "9" );
# Colors
normal_border_color = "#111111";
normal_bg_color = "#111111";
normal_fg_color = "#eeeeee";
focus_border_color = "#6666ff";
focus_bg_color = "#6666ff";
focus_fg_color = "#ffffff";
opacity_unfocused = 100;
# Available layouts colors
layouts = ( {
("[]=", "tile"), normal_border = "#111111"
("=[]", "tileleft"), normal_bg = "#111111"
("[ ]", "max"), normal_fg = "#eeeeee"
("><>", "floating") focus_border = "#6666ff"
); focus_bg = "#6666ff"
focus_fg = "#ffffff"
}
# Number of master windows (used by tile layouts) statusbar
nmaster = 2; {
ncols = 1; position = "top"
}
# Resize hints tags
resize_hints = true; {
tag 1
{
layout = "tile"
}
tag 2
{
layout = "tile"
}
tag 3
{
layout = "tile"
}
tag 4
{
layout = "tile"
}
tag 5
{
layout = "tile"
}
tag 6
{
layout = "tile"
}
tag 7
{
layout = "tile"
}
tag 8
{
layout = "tile"
}
tag 9
{
layout = "floating"
}
}
# Move pointer to the center of the focused window layouts
focus_move_pointer = false; {
mwfact = 0.5
nmaster = 1
ncol = 1
layout tile
{
symbol = "[]="
}
layout tileleft
{
symbol = "=[]"
}
# Set of rules to put some windows floating }
# or to tag them on launch
rules = ({ name = "Gimp";
tags = "";
float = true;
},
{ name = "MPlayer";
tags = "";
float = true;
},
{ name = "Acroread";
tags = "";
float = true;
},
{ name = "VLC";
tags = "";
float = true;
},
{ name = "pinentry";
tags = "";
float = true;
});
# modkey for mouse actions rules
modkey = "Mod4"; {
rule
{
name = "Gimp"
tags = ""
float = true
}
rule
{
name = "MPlayer"
float = true
}
rule
{
name = "Acroread"
float = true
}
rule
{
name = "pinentry"
float = true
}
}
# Keys binding keys
keys = ((("Mod4"), "Return", "spawn", "exec xterm"), {
(("Mod4"), "space", "setlayout", "+1"), modkey = "Mod4"
(("Mod4", "Shift"), "space", "setlayout", "-1"), key
(("Mod4"), "b", "togglebar"), {
(("Mod4"), "j", "focusnext"), modkey = {"Mod4"}
(("Mod4"), "k", "focusprev"), key = "Return"
(("Mod4", "Shift"), "j", "swapnext"), command = "spawn"
(("Mod4", "Shift"), "k", "swapprev"), arg = "exec xterm"
(("Mod4", "Control"), "j", "focusnextscreen"), }
(("Mod4", "Control"), "k", "focusprevscreen"), key
(("Mod4"), "h", "setmwfact", "-0.05"), {
(("Mod4"), "l", "setmwfact", "+0.05"), modkey = {"Mod4"}
(("Mod4"), "p", "setborder", "+1"), key = "space"
(("Mod4", "Shift"), "p", "setborder", "-1"), command = "setlayout"
(("Mod4", "Shift"), "h", "setnmaster", "+1"), arg = "+1"
(("Mod4", "Shift"), "l", "setnmaster", "-1"), }
(("Mod4", "Control"), "h", "setncols", "+1"), key
(("Mod4", "Control"), "l", "setncols", "-1"), {
(("Mod4"), "Escape", "view_tag_prev_selected"), modkey = {"Mod4", "Shift"}
(("Mod4", "Control"), "Left", "view_tag_previous"), key = "space"
(("Mod4", "Control"), "Right", "view_tag_next"), command = "setlayout"
(("Mod4"), "m", "togglemax"), arg = "-1"
(("Mod4"), "t", "settrans", "-5"), }
(("Mod4", "Shift"), "t", "settrans", "+5"), key
(("Mod4", "Control"), "Return", "zoom"), {
(("Mod4", "Control"), "space", "togglefloating"), modkey = {"Mod4"}
(("Mod4", "Shift"), "c", "killclient"), key = "b"
(("Mod4", "Shift"), "q", "quit"), command = "togglebar"
(("Mod4"), "0", "view"), }
(("Mod4"), "1", "view", "1"), key
(("Mod4"), "2", "view", "2"), {
(("Mod4"), "3", "view", "3"), modkey = {"Mod4"}
(("Mod4"), "4", "view", "4"), key = "j"
(("Mod4"), "5", "view", "5"), command = "focusnext"
(("Mod4"), "6", "view", "6"), }
(("Mod4"), "7", "view", "7"), key
(("Mod4"), "8", "view", "8"), {
(("Mod4"), "9", "view", "9"), modkey = {"Mod4"}
(("Mod4", "Control"), "0", "toggleview"), key = "k"
(("Mod4", "Control"), "1", "toggleview", "1"), command = "focusprev"
(("Mod4", "Control"), "2", "toggleview", "2"), }
(("Mod4", "Control"), "3", "toggleview", "3"), key
(("Mod4", "Control"), "4", "toggleview", "4"), {
(("Mod4", "Control"), "5", "toggleview", "5"), modkey = {"Mod4", "Shift"}
(("Mod4", "Control"), "6", "toggleview", "6"), key = "j"
(("Mod4", "Control"), "7", "toggleview", "7"), command = "swapprev"
(("Mod4", "Control"), "8", "toggleview", "8"), }
(("Mod4", "Control"), "9", "toggleview", "9"), key
(("Mod4", "Shift"), "0", "tag"), {
(("Mod4", "Shift"), "1", "tag", "1"), modkey = {"Mod4", "Shift"}
(("Mod4", "Shift"), "2", "tag", "2"), key = "k"
(("Mod4", "Shift"), "3", "tag", "3"), command = "swapnext"
(("Mod4", "Shift"), "4", "tag", "4"), }
(("Mod4", "Shift"), "5", "tag", "5"), key
(("Mod4", "Shift"), "6", "tag", "6"), {
(("Mod4", "Shift"), "7", "tag", "7"), modkey = {"Mod4", "Control"}
(("Mod4", "Shift"), "8", "tag", "8"), key = "j"
(("Mod4", "Shift"), "9", "tag", "9"), command = "focusnextscreen"
(("Mod4", "Shift", "Control"), "0", "toggletag"), }
(("Mod4", "Shift", "Control"), "1", "toggletag", "1"), key
(("Mod4", "Shift", "Control"), "2", "toggletag", "2"), {
(("Mod4", "Shift", "Control"), "3", "toggletag", "3"), modkey = {"Mod4", "Control"}
(("Mod4", "Shift", "Control"), "4", "toggletag", "4"), key = "k"
(("Mod4", "Shift", "Control"), "5", "toggletag", "5"), command = "focusprevscreen"
(("Mod4", "Shift", "Control"), "6", "toggletag", "6"), }
(("Mod4", "Shift", "Control"), "7", "toggletag", "7"), key
(("Mod4", "Shift", "Control"), "8", "toggletag", "8"), {
(("Mod4", "Shift", "Control"), "9", "toggletag", "9") modkey = {"Mod4"}
); key = "h"
}; command = "setmwfact"
arg = "-0.05"
}
key
{
modkey = {"Mod4"}
key = "l"
command = "setmwfact"
arg = "+0.05"
}
key
{
modkey = {"Mod4", "Shift"}
key = "h"
command = "setnmaster"
arg = "+1"
}
key
{
modkey = {"Mod4", "Shift"}
key = "l"
command = "setnmaster"
arg = "-1"
}
key
{
modkey = {"Mod4", "Control"}
key = "h"
command = "setncol"
arg = "+1"
}
key
{
modkey = {"Mod4", "Control"}
key = "l"
command = "setncol"
arg = "-1"
}
key
{
modkey = {"Mod4"}
key = "escape"
command = "view_tag_prev_selected"
}
key
{
modkey = {"Mod4"}
key = "Left"
command = "view_tag_previous"
}
key
{
modkey = {"Mod4"}
key = "Right"
command = "view_tag_next"
}
key
{
modkey = {"Mod4"}
key = "m"
command = "togglemax"
}
key
{
modkey = {"Mod4", "Control"}
key = "Return"
command = "zoom"
}
key
{
modkey = {"Mod4", "Control"}
key = "Space"
command = "togglefloating"
}
key
{
modkey = {"Mod4", "Shift"}
key = "c"
command = "killclient"
}
key
{
modkey = {"Mod4", "Shift"}
key = "q"
command = "quit"
}
key
{
modkey = {"Mod4"}
key = "0"
command = "view"
}
key
{
modkey = {"Mod4"}
key = "1"
command = "view"
arg = "1"
}
key
{
modkey = {"Mod4"}
key = "2"
command = "view"
arg = "2"
}
key
{
modkey = {"Mod4"}
key = "3"
command = "view"
arg = "3"
}
key
{
modkey = {"Mod4"}
key = "4"
command = "view"
arg = "5"
}
key
{
modkey = {"Mod4"}
key = "5"
command = "view"
arg = "5"
}
key
{
modkey = {"Mod4"}
key = "6"
command = "view"
arg = "6"
}
key
{
modkey = {"Mod4"}
key = "7"
command = "view"
arg = "7"
}
key
{
modkey = {"Mod4"}
key = "8"
command = "view"
arg = "8"
}
key
{
modkey = {"Mod4"}
key = "9"
command = "view"
arg = "9"
}
key
{
modkey = {"Mod4"}
key = "9"
command = "view"
arg = "9"
}
key
{
modkey = {"Mod4", "Control"}
key = "0"
command = "toggleview"
}
key
{
modkey = {"Mod4", "Control"}
key = "1"
command = "toggleview"
arg = "1"
}
key
{
modkey = {"Mod4", "Control"}
key = "2"
command = "toggleview"
arg = "2"
}
key
{
modkey = {"Mod4", "Control"}
key = "3"
command = "toggleview"
arg = "3"
}
key
{
modkey = {"Mod4", "Control"}
key = "4"
command = "toggleview"
arg = "4"
}
key
{
modkey = {"Mod4", "Control"}
key = "5"
command = "toggleview"
arg = "5"
}
key
{
modkey = {"Mod4", "Control"}
key = "6"
command = "toggleview"
arg = "6"
}
key
{
modkey = {"Mod4", "Control"}
key = "7"
command = "toggleview"
arg = "7"
}
key
{
modkey = {"Mod4", "Control"}
key = "8"
command = "toggleview"
arg = "8"
}
key
{
modkey = {"Mod4", "Control"}
key = "9"
command = "toggleview"
arg = "9"
}
key
{
modkey = {"Mod4", "Shift"}
key = "0"
command = "tag"
}
key
{
modkey = {"Mod4", "Shift"}
key = "1"
command = "tag"
arg = "1"
}
key
{
modkey = {"Mod4", "Shift"}
key = "2"
command = "tag"
arg = "2"
}
key
{
modkey = {"Mod4", "Shift"}
key = "3"
command = "tag"
arg = "3"
}
key
{
modkey = {"Mod4", "Shift"}
key = "4"
command = "tag"
arg = "4"
}
key
{
modkey = {"Mod4", "Shift"}
key = "5"
command = "tag"
arg = "5"
}
key
{
modkey = {"Mod4", "Shift"}
key = "6"
command = "tag"
arg = "6"
}
key
{
modkey = {"Mod4", "Shift"}
key = "7"
command = "tag"
arg = "7"
}
key
{
modkey = {"Mod4", "Shift"}
key = "8"
command = "tag"
arg = "8"
}
key
{
modkey = {"Mod4", "Shift"}
key = "9"
command = "tag"
arg = "9"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "0"
command = "toggletag"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "1"
command = "toggletag"
arg = "1"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "2"
command = "toggletag"
arg = "2"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "3"
command = "toggletag"
arg = "3"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "3"
command = "toggletag"
arg = "3"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "4"
command = "toggletag"
arg = "4"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "5"
command = "toggletag"
arg = "5"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "6"
command = "toggletag"
arg = "6"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "7"
command = "toggletag"
arg = "7"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "8"
command = "toggletag"
arg = "8"
}
key
{
modkey = {"Mod4", "Shift", "Control"}
key = "9"
command = "toggletag"
arg = "9"
}
}

402
config.c
View File

@ -24,7 +24,7 @@
* \defgroup ui_callback * \defgroup ui_callback
*/ */
#include <libconfig.h> #include <confuse.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include "awesome.h" #include "awesome.h"
@ -111,7 +111,7 @@ static const NameFuncLink KeyfuncList[] = {
/* layouts/tile.c */ /* layouts/tile.c */
{"setmwfact", uicb_setmwfact}, {"setmwfact", uicb_setmwfact},
{"setnmaster", uicb_setnmaster}, {"setnmaster", uicb_setnmaster},
{"setncols", uicb_setncols}, {"setncol", uicb_setncol},
/* screen.c */ /* screen.c */
{"focusnextscreen", uicb_focusnextscreen}, {"focusnextscreen", uicb_focusnextscreen},
{"focusprevscreen", uicb_focusprevscreen}, {"focusprevscreen", uicb_focusprevscreen},
@ -167,14 +167,95 @@ name_func_lookup(const char *funcname, const NameFuncLink * list)
void void
parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg, awesome_config *awesomeconf) parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg, awesome_config *awesomeconf)
{ {
/* Main configuration object for parsing*/ static cfg_opt_t general_opts[] =
config_t awesomelibconf; {
config_setting_t *conftags; CFG_INT((char *) "border", 1, CFGF_NONE),
config_setting_t *conflayouts, *confsublayouts; CFG_INT((char *) "snap", 8, CFGF_NONE),
config_setting_t *confrules, *confsubrules; CFG_BOOL((char *) "resize_hints", cfg_false, CFGF_NONE),
config_setting_t *confkeys, *confsubkeys, *confkeysmasks, *confkeymaskelem; CFG_INT((char *) "opacity_unfocused", 100, CFGF_NONE),
int i = 0, j = 0; CFG_BOOL((char *) "focus_move_pointer", cfg_false, CFGF_NONE),
double f = 0.0; CFG_STR((char *) "font", (char *) "mono-12", CFGF_NONE),
CFG_END()
};
static cfg_opt_t colors_opts[] =
{
CFG_STR((char *) "normal_border", (char *) "#111111", CFGF_NONE),
CFG_STR((char *) "normal_bg", (char *) "#111111", CFGF_NONE),
CFG_STR((char *) "normal_fg", (char *) "#eeeeee", CFGF_NONE),
CFG_STR((char *) "focus_border", (char *) "#6666ff", CFGF_NONE),
CFG_STR((char *) "focus_bg", (char *) "#6666ff", CFGF_NONE),
CFG_STR((char *) "focus_fg", (char *) "#ffffff", CFGF_NONE),
CFG_END()
};
static cfg_opt_t statusbar_opts[] =
{
CFG_STR((char *) "position", (char *) "top", CFGF_NONE),
CFG_END()
};
static cfg_opt_t tag_opts[] =
{
CFG_STR((char *) "layout", (char *) "tile", CFGF_NONE),
CFG_END()
};
static cfg_opt_t tags_opts[] =
{
CFG_SEC((char *) "tag", tag_opts, CFGF_TITLE | CFGF_MULTI),
CFG_END()
};
static cfg_opt_t layout_opts[] =
{
CFG_STR((char *) "symbol", (char *) "???", CFGF_NONE),
CFG_END()
};
static cfg_opt_t layouts_opts[] =
{
CFG_SEC((char *) "layout", layout_opts, CFGF_TITLE | CFGF_MULTI),
CFG_FLOAT((char *) "mwfact", 0.5, CFGF_NONE),
CFG_INT((char *) "nmaster", 1, CFGF_NONE),
CFG_INT((char *) "ncol", 1, CFGF_NONE),
CFG_END()
};
static cfg_opt_t rule_opts[] =
{
CFG_STR((char *) "name", (char *) "", CFGF_NONE),
CFG_STR((char *) "tags", (char *) "", CFGF_NONE),
CFG_BOOL((char *) "float", cfg_false, CFGF_NONE),
CFG_END()
};
static cfg_opt_t rules_opts[] =
{
CFG_SEC((char *) "rule", rule_opts, CFGF_MULTI),
CFG_END()
};
static cfg_opt_t key_opts[] =
{
CFG_STR_LIST((char *) "modkey", (char *) "{Mod4}", CFGF_NONE),
CFG_STR((char *) "key", (char *) "None", CFGF_NONE),
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
CFG_STR((char *) "arg", NULL, CFGF_NONE),
CFG_END()
};
static cfg_opt_t keys_opts[] =
{
CFG_STR((char *) "modkey", (char *) "Mod4", CFGF_NONE),
CFG_SEC((char *) "key", key_opts, CFGF_MULTI),
CFG_END()
};
static cfg_opt_t opts[] =
{
CFG_SEC((char *) "general", general_opts, CFGF_NONE),
CFG_SEC((char *) "colors", colors_opts, CFGF_NONE),
CFG_SEC((char *) "statusbar", statusbar_opts, CFGF_NONE),
CFG_SEC((char *) "tags", tags_opts, CFGF_NONE),
CFG_SEC((char *) "layouts", layouts_opts, CFGF_NONE),
CFG_SEC((char *) "rules", rules_opts, CFGF_NONE),
CFG_SEC((char *) "keys", keys_opts, CFGF_NONE),
CFG_END()
};
cfg_t *cfg, *cfg_general, *cfg_colors, *cfg_statusbar,
*cfg_tags, *cfg_layouts, *cfg_rules, *cfg_keys, *cfgsectmp;
int i = 0;
unsigned int j = 0;
const char *tmp, *homedir; const char *tmp, *homedir;
char *confpath; char *confpath;
KeySym tmp_key; KeySym tmp_key;
@ -193,8 +274,6 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE); a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE);
} }
config_init(&awesomelibconf);
a_strcpy(awesomeconf->statustext, sizeof(awesomeconf->statustext), "awesome-" VERSION); a_strcpy(awesomeconf->statustext, sizeof(awesomeconf->statustext), "awesome-" VERSION);
/* store display */ /* store display */
@ -204,167 +283,49 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
awesomeconf->screen = scr; awesomeconf->screen = scr;
awesomeconf->phys_screen = get_phys_screen(disp, scr); awesomeconf->phys_screen = get_phys_screen(disp, scr);
if(config_read_file(&awesomelibconf, confpath) == CONFIG_FALSE) cfg = cfg_init(opts, CFGF_NONE);
fprintf(stderr, "awesome: error parsing configuration file at line %d: %s\n",
config_error_line(&awesomelibconf), config_error_text(&awesomelibconf));
if(cfg_parse(cfg, confpath) == CFG_PARSE_ERROR)
fprintf(stderr, "awesome: error parsing configuration file\n");
/* font */ cfg_general = cfg_getsec(cfg, "general");
tmp = config_lookup_string(&awesomelibconf, "awesome.font"); cfg_colors = cfg_getsec(cfg, "colors");
drawcontext->font = XftFontOpenName(disp, awesomeconf->phys_screen, tmp ? tmp : "sans-12"); cfg_statusbar = cfg_getsec(cfg, "statusbar");
cfg_tags = cfg_getsec(cfg, "tags");
cfg_layouts = cfg_getsec(cfg, "layouts");
cfg_rules = cfg_getsec(cfg, "rules");
cfg_keys = cfg_getsec(cfg, "keys");
/* General section */
awesomeconf->borderpx = cfg_getint(cfg_general, "border");
awesomeconf->snap = cfg_getint(cfg_general, "snap");
awesomeconf->resize_hints = cfg_getbool(cfg_general, "resize_hints");
awesomeconf->opacity_unfocused = cfg_getint(cfg_general, "opacity_unfocused");
awesomeconf->focus_move_pointer = cfg_getbool(cfg_general, "focus_move_pointer");
drawcontext->font = XftFontOpenName(disp, awesomeconf->phys_screen, cfg_getstr(cfg_general, "font"));
if(!drawcontext->font) if(!drawcontext->font)
eprint("awesome: cannot init font\n"); eprint("awesome: cannot init font\n");
/* layouts */ /* Colors */
conflayouts = config_lookup(&awesomelibconf, "awesome.layouts"); drawcontext->norm[ColBorder] = initxcolor(disp, awesomeconf->phys_screen,
cfg_getstr(cfg_colors, "normal_border")).pixel;
drawcontext->norm[ColBG] = initxcolor(disp, awesomeconf->phys_screen,
cfg_getstr(cfg_colors, "normal_bg")).pixel;
drawcontext->sel[ColBorder] = initxcolor(disp, awesomeconf->phys_screen,
cfg_getstr(cfg_colors, "focus_border")).pixel;
drawcontext->sel[ColBG] = initxcolor(disp, awesomeconf->phys_screen,
cfg_getstr(cfg_colors, "focus_bg")).pixel;
if(!conflayouts) colorbuf = initxcolor(disp, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "normal_fg"));
{ drawcontext->norm[ColFG] = colorbuf.pixel;
fprintf(stderr, "awesome: layouts not found in configuration file, setting default\n"); drawcontext->text_normal = colorbuf;
awesomeconf->nlayouts = 2; colorbuf = initxcolor(disp, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "focus_fg"));
awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts + 1); drawcontext->sel[ColFG] = colorbuf.pixel;
awesomeconf->layouts[0].symbol = a_strdup("[]="); drawcontext->text_selected = colorbuf;
awesomeconf->layouts[0].arrange = layout_tile;
awesomeconf->layouts[1].symbol = a_strdup("<><");
awesomeconf->layouts[1].arrange = layout_floating;
awesomeconf->layouts[2].symbol = NULL;
awesomeconf->layouts[2].arrange = NULL;
}
else
{
awesomeconf->nlayouts = config_setting_length(conflayouts);
awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts + 1);
for(i = 0; (confsublayouts = config_setting_get_elem(conflayouts, i)); i++)
{
awesomeconf->layouts[i].arrange =
name_func_lookup(config_setting_get_string_elem(confsublayouts, 1), LayoutsList);
if(!awesomeconf->layouts[i].arrange)
{
fprintf(stderr, "awesome: unknown layout #%d in configuration file\n", i);
awesomeconf->layouts[i].symbol = NULL;
continue;
}
awesomeconf->layouts[i].symbol = a_strdup(config_setting_get_string_elem(confsublayouts, 0));
}
awesomeconf->layouts[i].symbol = NULL;
awesomeconf->layouts[i].arrange = NULL;
}
awesomeconf->current_layout = awesomeconf->layouts; /* Statusbar */
tmp = cfg_getstr(cfg_statusbar, "position");
if(!awesomeconf->nlayouts || !awesomeconf->current_layout->arrange)
eprint("awesome: fatal: no default layout available\n");
for(i = 0; i < awesomeconf->nlayouts; i++)
{
j = drawcontext->font->height +
textwidth(disp, drawcontext->font,
awesomeconf->layouts[i].symbol, a_strlen(awesomeconf->layouts[i].symbol));
if(j > awesomeconf->statusbar.width)
awesomeconf->statusbar.width = j;
}
/* tags */
conftags = config_lookup(&awesomelibconf, "awesome.tags");
if(!conftags)
{
fprintf(stderr, "awesome: tags not found in configuration file, setting default\n");
awesomeconf->ntags = 3;
awesomeconf->tags = p_new(Tag, awesomeconf->ntags);
awesomeconf->tags[0].name = a_strdup("this");
awesomeconf->tags[1].name = a_strdup("is");
awesomeconf->tags[2].name = a_strdup("awesome");
awesomeconf->tags[0].selected = True;
awesomeconf->tags[1].selected = False;
awesomeconf->tags[2].selected = False;
awesomeconf->tags[0].was_selected = False;
awesomeconf->tags[1].was_selected = False;
awesomeconf->tags[2].was_selected = False;
awesomeconf->tags[0].layout = awesomeconf->layouts;
awesomeconf->tags[1].layout = awesomeconf->layouts;
awesomeconf->tags[2].layout = awesomeconf->layouts;
}
else
{
awesomeconf->ntags = config_setting_length(conftags);
awesomeconf->tags = p_new(Tag, awesomeconf->ntags);
for(i = 0; (tmp = config_setting_get_string_elem(conftags, i)); i++)
{
awesomeconf->tags[i].name = a_strdup(tmp);
awesomeconf->tags[i].selected = False;
awesomeconf->tags[i].was_selected = False;
/** \todo add support for default tag/layout in configuration file */
awesomeconf->tags[i].layout = awesomeconf->layouts;
}
}
if(!awesomeconf->ntags)
eprint("awesome: fatal: no tags found in configuration file\n");
/* select first tag by default */
awesomeconf->tags[0].selected = True;
awesomeconf->tags[0].was_selected = True;
/* rules */
confrules = config_lookup(&awesomelibconf, "awesome.rules");
if(!confrules)
{
awesomeconf->nrules = 0;
fprintf(stderr, "awesome: no rules found in configuration file\n");
}
else
{
awesomeconf->nrules = config_setting_length(confrules);
awesomeconf->rules = p_new(Rule, awesomeconf->nrules);
for(i = 0; (confsubrules = config_setting_get_elem(confrules, i)); i++)
{
awesomeconf->rules[i].prop = a_strdup(config_setting_get_string(config_setting_get_member(confsubrules, "name")));
awesomeconf->rules[i].tags = a_strdup(config_setting_get_string(config_setting_get_member(confsubrules, "tags")));
if(awesomeconf->rules[i].tags && !a_strlen(awesomeconf->rules[i].tags))
awesomeconf->rules[i].tags = NULL;
awesomeconf->rules[i].isfloating =
config_setting_get_bool(config_setting_get_member(confsubrules, "float"));
}
}
/* modkey */
tmp_key = key_mask_lookup(config_lookup_string(&awesomelibconf, "awesome.modkey"));
awesomeconf->modkey = tmp_key ? tmp_key : Mod1Mask;
/* find numlock mask */
awesomeconf->numlockmask = get_numlockmask(disp);
/* keys */
confkeys = config_lookup(&awesomelibconf, "awesome.keys");
if(!confkeys)
{
awesomeconf->nkeys = 0;
fprintf(stderr, "awesome: no keys found in configuration file\n");
}
else
{
awesomeconf->nkeys = config_setting_length(confkeys);
awesomeconf->keys = p_new(Key, awesomeconf->nkeys);
for(i = 0; (confsubkeys = config_setting_get_elem(confkeys, i)); i++)
{
confkeysmasks = config_setting_get_elem(confsubkeys, 0);
for(j = 0; (confkeymaskelem = config_setting_get_elem(confkeysmasks, j)); j++)
awesomeconf->keys[i].mod |= key_mask_lookup(config_setting_get_string(confkeymaskelem));
awesomeconf->keys[i].keysym = XStringToKeysym(config_setting_get_string_elem(confsubkeys, 1));
awesomeconf->keys[i].func =
name_func_lookup(config_setting_get_string_elem(confsubkeys, 2), KeyfuncList);
awesomeconf->keys[i].arg = a_strdup(config_setting_get_string_elem(confsubkeys, 3));
}
}
/* barpos */
tmp = config_lookup_string(&awesomelibconf, "awesome.barpos");
if(tmp && !a_strncmp(tmp, "off", 6)) if(tmp && !a_strncmp(tmp, "off", 6))
awesomeconf->statusbar_default_position = BarOff; awesomeconf->statusbar_default_position = BarOff;
@ -375,64 +336,85 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
awesomeconf->statusbar.position = awesomeconf->statusbar_default_position; awesomeconf->statusbar.position = awesomeconf->statusbar_default_position;
/* borderpx */ /* Layouts */
awesomeconf->borderpx = config_lookup_int(&awesomelibconf, "awesome.borderpx");
/* opacity */ awesomeconf->nlayouts = cfg_size(cfg_layouts, "layout");
awesomeconf->opacity_unfocused = config_lookup_int(&awesomelibconf, "awesome.opacity_unfocused"); awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts);
if(awesomeconf->opacity_unfocused >= 100 || awesomeconf->opacity_unfocused == 0) for(i = 0; i < awesomeconf->nlayouts; i++)
awesomeconf->opacity_unfocused = -1; {
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
awesomeconf->layouts[i].arrange = name_func_lookup(cfg_title(cfgsectmp), LayoutsList);
if(!awesomeconf->layouts[i].arrange)
{
fprintf(stderr, "awesome: unknown layout #%d in configuration file\n", i);
awesomeconf->layouts[i].symbol = NULL;
continue;
}
awesomeconf->layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
}
/* snap */ awesomeconf->mwfact = cfg_getfloat(cfg_layouts, "mwfact");
i = config_lookup_int(&awesomelibconf, "awesome.snap"); awesomeconf->nmaster = cfg_getint(cfg_layouts, "nmaster");
awesomeconf->snap = i ? i : 8; awesomeconf->ncol = cfg_getint(cfg_layouts, "ncol");
/* nmaster */ awesomeconf->current_layout = awesomeconf->layouts;
i = config_lookup_int(&awesomelibconf, "awesome.nmaster");
awesomeconf->nmaster = i ? i : 1;
/* ncols */ if(!awesomeconf->nlayouts || !awesomeconf->current_layout->arrange)
i = config_lookup_int(&awesomelibconf, "awesome.ncols"); eprint("awesome: fatal: no default layout available\n");
awesomeconf->ncols = i ? i : 1;
/* mwfact */ /* Rules */
f = config_lookup_float(&awesomelibconf, "awesome.mwfact");
awesomeconf->mwfact = f ? f : 0.6;
/* resize_hints */ awesomeconf->nrules = cfg_size(cfg_rules, "rule");
awesomeconf->resize_hints = config_lookup_bool(&awesomelibconf, "awesome.resize_hints"); awesomeconf->rules = p_new(Rule, awesomeconf->nrules);
for(i = 0; i < awesomeconf->nrules; i++)
{
cfgsectmp = cfg_getnsec(cfg_rules, "rule", i);
awesomeconf->rules[i].prop = a_strdup(cfg_getstr(cfgsectmp, "name"));
awesomeconf->rules[i].tags = a_strdup(cfg_getstr(cfgsectmp, "tags"));
if(!a_strlen(awesomeconf->rules[i].tags))
awesomeconf->rules[i].tags = NULL;
awesomeconf->rules[i].isfloating = cfg_getbool(cfgsectmp, "float");
}
/* focus_move_pointer */ /* Tags */
awesomeconf->focus_move_pointer = config_lookup_bool(&awesomelibconf, "awesome.focus_move_pointer");
/* colors */ awesomeconf->ntags = cfg_size(cfg_tags, "tag");
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_border_color"); awesomeconf->tags = p_new(Tag, awesomeconf->ntags);
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#dddddd"); for(i = 0; i < awesomeconf->ntags; i++)
drawcontext->norm[ColBorder] = colorbuf.pixel; {
cfgsectmp = cfg_getnsec(cfg_tags, "tag", i);
awesomeconf->tags[i].name = a_strdup(cfg_title(cfgsectmp));
awesomeconf->tags[i].selected = False;
awesomeconf->tags[i].was_selected = False;
awesomeconf->tags[i].layout = awesomeconf->layouts;
}
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_bg_color"); if(!awesomeconf->ntags)
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#000000"); eprint("awesome: fatal: no tags found in configuration file\n");
drawcontext->norm[ColBG] = colorbuf.pixel;
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_fg_color"); /* select first tag by default */
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff"); awesomeconf->tags[0].selected = True;
drawcontext->norm[ColFG] = colorbuf.pixel; awesomeconf->tags[0].was_selected = True;
drawcontext->text_normal = colorbuf;
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_border_color"); /* Keys */
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b"); tmp_key = key_mask_lookup(cfg_getstr(cfg_keys, "modkey"));
drawcontext->sel[ColBorder] = colorbuf.pixel; awesomeconf->modkey = tmp_key ? tmp_key : Mod4Mask;
awesomeconf->numlockmask = get_numlockmask(disp);
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_bg_color"); awesomeconf->nkeys = cfg_size(cfg_keys, "key");
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b"); awesomeconf->keys = p_new(Key, awesomeconf->nkeys);
drawcontext->sel[ColBG] = colorbuf.pixel; for(i = 0; i < awesomeconf->nkeys; i++)
{
cfgsectmp = cfg_getnsec(cfg_keys, "key", i);
for(j = 0; j < cfg_size(cfgsectmp, "modkey"); j++)
awesomeconf->keys[i].mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", j));
awesomeconf->keys[i].keysym = XStringToKeysym(cfg_getstr(cfgsectmp, "key"));
awesomeconf->keys[i].func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), KeyfuncList);
awesomeconf->keys[i].arg = a_strdup(cfg_getstr(cfgsectmp, "arg"));
}
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color"); /* Free! Like a river! */
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff"); cfg_free(cfg);
drawcontext->sel[ColFG] = colorbuf.pixel;
drawcontext->text_selected = colorbuf;
config_destroy(&awesomelibconf);
p_delete(&confpath); p_delete(&confpath);
} }

View File

@ -142,7 +142,7 @@ struct awesome_config
/** Number of master windows */ /** Number of master windows */
int nmaster; int nmaster;
/** Number of columns in tile layout */ /** Number of columns in tile layout */
int ncols; int ncol;
/** Transparency of unfocused clients */ /** Transparency of unfocused clients */
int opacity_unfocused; int opacity_unfocused;
/** Focus move pointer */ /** Focus move pointer */

View File

@ -14,8 +14,8 @@ X11INC = /usr/include/X11
X11LIB = /usr/lib/X11 X11LIB = /usr/lib/X11
# includes and libs # includes and libs
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig xft` INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfuse xft`
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig xft` -lXext -lXrandr -lXinerama LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfuse xft` -lXext -lXrandr -lXinerama
# flags # flags
CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O3 ${INCS} -DVERSION=\"${VERSION}\" CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O3 ${INCS} -DVERSION=\"${VERSION}\"

View File

@ -48,16 +48,16 @@ uicb_setnmaster(Display *disp,
} }
void void
uicb_setncols(Display *disp, uicb_setncol(Display *disp,
DC * drawcontext, DC * drawcontext,
awesome_config *awesomeconf, awesome_config *awesomeconf,
const char * arg) const char * arg)
{ {
if(!arg || (!IS_ARRANGE(layout_tile) && !IS_ARRANGE(layout_tileleft))) if(!arg || (!IS_ARRANGE(layout_tile) && !IS_ARRANGE(layout_tileleft)))
return; return;
if((awesomeconf->ncols = (int) compute_new_value_from_arg(arg, (double) awesomeconf->ncols)) < 1) if((awesomeconf->ncol = (int) compute_new_value_from_arg(arg, (double) awesomeconf->ncol)) < 1)
awesomeconf->ncols = 1; awesomeconf->ncol = 1;
arrange(disp, drawcontext, awesomeconf); arrange(disp, drawcontext, awesomeconf);
} }
@ -101,7 +101,7 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right)
/* master size */ /* master size */
unsigned int mw = 0, mh = 0; unsigned int mw = 0, mh = 0;
int n, i, masterwin = 0, otherwin = 0; int n, i, masterwin = 0, otherwin = 0;
int real_ncols = 1, win_by_col = 1, current_col = 0; int real_ncol = 1, win_by_col = 1, current_col = 0;
ScreenInfo *screens_info = NULL; ScreenInfo *screens_info = NULL;
Client *c; Client *c;
@ -131,7 +131,7 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right)
else else
mh = mw = 0; mh = mw = 0;
real_ncols = MIN(otherwin, awesomeconf->ncols); real_ncol = MIN(otherwin, awesomeconf->ncol);
for(i = 0, c = clients; c; c = c->next) for(i = 0, c = clients; c; c = c->next)
{ {
@ -147,23 +147,23 @@ _tile(Display *disp, awesome_config *awesomeconf, const Bool right)
} }
else else
{ /* tile window */ { /* tile window */
if(real_ncols) if(real_ncol)
win_by_col = otherwin / real_ncols; win_by_col = otherwin / real_ncol;
if((i - awesomeconf->nmaster) && (i - awesomeconf->nmaster) % win_by_col == 0 && current_col < real_ncols - 1) if((i - awesomeconf->nmaster) && (i - awesomeconf->nmaster) % win_by_col == 0 && current_col < real_ncol - 1)
current_col++; current_col++;
if(current_col == real_ncols - 1) if(current_col == real_ncol - 1)
win_by_col += otherwin % real_ncols; win_by_col += otherwin % real_ncol;
if(otherwin <= real_ncols) if(otherwin <= real_ncol)
nh = wah - 2 * c->border; nh = wah - 2 * c->border;
else else
nh = (wah / win_by_col) - 2 * c->border; nh = (wah / win_by_col) - 2 * c->border;
nw = (waw - mw) / real_ncols - 2 * c->border; nw = (waw - mw) / real_ncol - 2 * c->border;
if(i == awesomeconf->nmaster || otherwin <= real_ncols || (i - awesomeconf->nmaster) % win_by_col == 0) if(i == awesomeconf->nmaster || otherwin <= real_ncol || (i - awesomeconf->nmaster) % win_by_col == 0)
ny = way; ny = way;
else else
ny = way + ((i - awesomeconf->nmaster) % win_by_col) * (nh + 2 * c->border); ny = way + ((i - awesomeconf->nmaster) % win_by_col) * (nh + 2 * c->border);

View File

@ -29,7 +29,7 @@ LAYOUT_PROTO(layout_tile);
LAYOUT_PROTO(layout_tileleft); LAYOUT_PROTO(layout_tileleft);
UICB_PROTO(uicb_setnmaster); UICB_PROTO(uicb_setnmaster);
UICB_PROTO(uicb_setncols); UICB_PROTO(uicb_setncol);
UICB_PROTO(uicb_setmwfact); UICB_PROTO(uicb_setmwfact);
#endif #endif

View File

@ -94,7 +94,7 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
else if(IS_ARRANGE(layout_tile) || IS_ARRANGE(layout_tileleft)) else if(IS_ARRANGE(layout_tile) || IS_ARRANGE(layout_tileleft))
{ {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), "nmaster: %d ncols: %d mwfact: %.2lf", awesomeconf->nmaster, awesomeconf->ncols, awesomeconf->mwfact); snprintf(buf, sizeof(buf), "nmaster: %d ncol: %d mwfact: %.2lf", awesomeconf->nmaster, awesomeconf->ncol, awesomeconf->mwfact);
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, buf, drawcontext->norm, drawcontext->text_normal); drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, buf, drawcontext->norm, drawcontext->text_normal);
} }
else else