2007-10-03 17:26:14 +02:00
|
|
|
/*
|
2007-09-12 14:29:51 +02:00
|
|
|
* config.c - configuration management
|
2007-10-03 17:26:14 +02:00
|
|
|
*
|
2008-01-02 16:59:43 +01:00
|
|
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
2007-10-03 17:26:14 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2007-09-12 14:29:51 +02:00
|
|
|
*/
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/**
|
2007-12-19 04:26:20 +01:00
|
|
|
* @defgroup ui_callback User Interface Callbacks
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
2007-11-15 14:41:03 +01:00
|
|
|
#include "statusbar.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "rules.h"
|
|
|
|
#include "screen.h"
|
2007-12-15 18:21:02 +01:00
|
|
|
#include "widget.h"
|
2007-12-19 03:20:21 +01:00
|
|
|
#include "xutil.h"
|
2007-12-27 18:18:12 +01:00
|
|
|
#include "ewmh.h"
|
2007-12-13 11:16:43 +01:00
|
|
|
#include "defconfig.h"
|
2007-12-27 23:28:33 +01:00
|
|
|
#include "layouts/tile.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-10-12 13:09:59 +02:00
|
|
|
#define AWESOME_CONFIG_FILE ".awesomerc"
|
|
|
|
|
2007-12-19 04:46:44 +01:00
|
|
|
extern AwesomeConf globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/** Link a name to a key symbol */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
KeySym keysym;
|
|
|
|
} KeyMod;
|
|
|
|
|
2007-11-11 15:40:01 +01:00
|
|
|
/** Link a name to a mouse button symbol */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
unsigned int button;
|
|
|
|
} MouseButton;
|
|
|
|
|
2007-11-15 14:41:03 +01:00
|
|
|
extern const NameFuncLink UicbList[];
|
2007-12-15 18:21:02 +01:00
|
|
|
extern const NameFuncLink WidgetList[];
|
2007-12-16 13:22:13 +01:00
|
|
|
extern const NameFuncLink LayoutsList[];
|
2007-10-12 17:10:36 +02:00
|
|
|
|
2007-12-19 03:20:21 +01:00
|
|
|
|
2007-12-16 13:22:13 +01:00
|
|
|
static unsigned int
|
|
|
|
get_numlockmask(Display *disp)
|
2007-10-12 17:10:36 +02:00
|
|
|
{
|
2007-12-16 13:22:13 +01:00
|
|
|
XModifierKeymap *modmap;
|
|
|
|
unsigned int mask = 0;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
modmap = XGetModifierMapping(disp);
|
|
|
|
for(i = 0; i < 8; i++)
|
|
|
|
for(j = 0; j < modmap->max_keypermod; j++)
|
|
|
|
if(modmap->modifiermap[i * modmap->max_keypermod + j]
|
|
|
|
== XKeysymToKeycode(disp, XK_Num_Lock))
|
|
|
|
mask = (1 << i);
|
|
|
|
|
|
|
|
XFreeModifiermap(modmap);
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
/** Lookup for a key mask from its name
|
|
|
|
* \param keyname Key name
|
|
|
|
* \return Key mask or 0 if not found
|
|
|
|
*/
|
|
|
|
static KeySym
|
|
|
|
key_mask_lookup(const char *keyname)
|
|
|
|
{
|
2007-12-16 13:22:13 +01:00
|
|
|
/** List of keyname and corresponding X11 mask codes */
|
|
|
|
static const KeyMod KeyModList[] =
|
|
|
|
{
|
|
|
|
{"Shift", ShiftMask},
|
|
|
|
{"Lock", LockMask},
|
|
|
|
{"Control", ControlMask},
|
|
|
|
{"Mod1", Mod1Mask},
|
|
|
|
{"Mod2", Mod2Mask},
|
|
|
|
{"Mod3", Mod3Mask},
|
|
|
|
{"Mod4", Mod4Mask},
|
|
|
|
{"Mod5", Mod5Mask},
|
|
|
|
{NULL, NoSymbol}
|
|
|
|
};
|
2007-09-05 20:15:00 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if(keyname)
|
|
|
|
for(i = 0; KeyModList[i].name; i++)
|
2007-09-21 17:32:00 +02:00
|
|
|
if(!a_strcmp(keyname, KeyModList[i].name))
|
2007-09-05 20:15:00 +02:00
|
|
|
return KeyModList[i].keysym;
|
|
|
|
|
2007-11-12 10:53:48 +01:00
|
|
|
return NoSymbol;
|
2007-09-06 23:29:50 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-11-11 15:40:01 +01:00
|
|
|
/** Lookup for a mouse button from its name
|
|
|
|
* \param button Mouse button name
|
|
|
|
* \return Mouse button or 0 if not found
|
|
|
|
*/
|
|
|
|
static unsigned int
|
|
|
|
mouse_button_lookup(const char *button)
|
|
|
|
{
|
2007-12-16 13:22:13 +01:00
|
|
|
/** List of button name and corresponding X11 mask codes */
|
|
|
|
static const MouseButton MouseButtonList[] =
|
|
|
|
{
|
|
|
|
{"1", Button1},
|
|
|
|
{"2", Button2},
|
|
|
|
{"3", Button3},
|
|
|
|
{"4", Button4},
|
|
|
|
{"5", Button5},
|
|
|
|
{NULL, 0}
|
|
|
|
};
|
2007-11-11 15:40:01 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if(button)
|
|
|
|
for(i = 0; MouseButtonList[i].name; i++)
|
|
|
|
if(!a_strcmp(button, MouseButtonList[i].name))
|
|
|
|
return MouseButtonList[i].button;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-12 13:21:28 +01:00
|
|
|
static Button *
|
|
|
|
parse_mouse_bindings(cfg_t * cfg, const char *secname, Bool handle_arg)
|
2007-11-12 11:59:57 +01:00
|
|
|
{
|
2007-11-12 13:21:28 +01:00
|
|
|
unsigned int i, j;
|
2007-11-12 11:59:57 +01:00
|
|
|
cfg_t *cfgsectmp;
|
2007-11-12 13:21:28 +01:00
|
|
|
Button *b = NULL, *head = NULL;
|
2007-11-12 11:59:57 +01:00
|
|
|
|
|
|
|
/* Mouse: layout click bindings */
|
2007-11-12 13:21:28 +01:00
|
|
|
for(i = 0; i < cfg_size(cfg, secname); i++)
|
2007-11-12 11:59:57 +01:00
|
|
|
{
|
2007-11-12 13:21:28 +01:00
|
|
|
/* init first elem */
|
|
|
|
if(i == 0)
|
|
|
|
head = b = p_new(Button, 1);
|
|
|
|
|
2007-11-12 11:59:57 +01:00
|
|
|
cfgsectmp = cfg_getnsec(cfg, secname, i);
|
|
|
|
for(j = 0; j < cfg_size(cfgsectmp, "modkey"); j++)
|
2007-11-12 13:21:28 +01:00
|
|
|
b->mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", j));
|
|
|
|
b->button = mouse_button_lookup(cfg_getstr(cfgsectmp, "button"));
|
|
|
|
b->func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), UicbList);
|
2007-11-14 18:28:28 +01:00
|
|
|
if(!b->func)
|
2007-12-13 02:40:45 +01:00
|
|
|
warn("unknown command %s\n", cfg_getstr(cfgsectmp, "command"));
|
2007-11-12 12:07:18 +01:00
|
|
|
if(handle_arg)
|
2007-11-12 13:21:28 +01:00
|
|
|
b->arg = a_strdup(cfg_getstr(cfgsectmp, "arg"));
|
2007-11-12 12:07:18 +01:00
|
|
|
else
|
2007-11-12 13:21:28 +01:00
|
|
|
b->arg = NULL;
|
|
|
|
|
|
|
|
/* switch to next elem or finalize the list */
|
|
|
|
if(i < cfg_size(cfg, secname) - 1)
|
|
|
|
{
|
|
|
|
b->next = p_new(Button, 1);
|
|
|
|
b = b->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
b->next = NULL;
|
2007-11-12 11:59:57 +01:00
|
|
|
}
|
2007-11-12 13:21:28 +01:00
|
|
|
|
|
|
|
return head;
|
2007-11-12 11:59:57 +01:00
|
|
|
}
|
|
|
|
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
|
2008-01-03 17:09:27 +01:00
|
|
|
static void
|
|
|
|
set_key_info(Key *key, cfg_t *cfg)
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
{
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
for(j = 0; j < cfg_size(cfg, "modkey"); j++)
|
|
|
|
key->mod |= key_mask_lookup(cfg_getnstr(cfg, "modkey", j));
|
|
|
|
key->func = name_func_lookup(cfg_getstr(cfg, "command"), UicbList);
|
|
|
|
if(!key->func)
|
2007-12-13 14:03:55 +01:00
|
|
|
warn("unknown command %s\n", cfg_getstr(cfg, "command"));
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-03 17:09:27 +01:00
|
|
|
static Key *
|
|
|
|
section_keys(cfg_t *cfg_keys)
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
{
|
|
|
|
Key *key, *head;
|
|
|
|
unsigned int i, j, numkeys;
|
|
|
|
cfg_t *cfgkeytmp;
|
|
|
|
|
|
|
|
head = key = NULL;
|
|
|
|
for(i = 0; i < cfg_size(cfg_keys, "key"); i++)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
key = head = p_new(Key, 1);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
key->next = p_new(Key, 1);
|
|
|
|
key = key->next;
|
|
|
|
}
|
|
|
|
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
|
|
|
set_key_info(key, cfgkeytmp);
|
|
|
|
key->keysym = XStringToKeysym(cfg_getstr(cfgkeytmp, "key"));
|
|
|
|
key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < cfg_size(cfg_keys, "keylist"); i++)
|
|
|
|
{
|
|
|
|
cfgkeytmp = cfg_getnsec(cfg_keys, "keylist", i);
|
|
|
|
numkeys = cfg_size(cfgkeytmp, "keylist");
|
|
|
|
if (numkeys != cfg_size(cfgkeytmp, "arglist"))
|
|
|
|
{
|
2007-12-13 14:03:55 +01:00
|
|
|
warn("number of keys != number of args in keylist");
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for(j=0; j < numkeys; j++)
|
|
|
|
{
|
|
|
|
if (head == NULL)
|
|
|
|
{
|
|
|
|
key = p_new(Key, 1);
|
|
|
|
head = key;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
key->next = p_new(Key, 1);
|
|
|
|
key = key->next;
|
|
|
|
}
|
|
|
|
set_key_info(key, cfgkeytmp);
|
|
|
|
key->keysym = XStringToKeysym(cfg_getnstr(cfgkeytmp, "keylist", j));
|
|
|
|
key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
|
|
|
|
if(j < numkeys - 1)
|
|
|
|
{
|
|
|
|
key->next = p_new(Key, 1);
|
|
|
|
key = key->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (key)
|
|
|
|
key->next = NULL;
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
2007-12-16 08:41:10 +01:00
|
|
|
|
|
|
|
static int
|
2007-12-16 13:22:13 +01:00
|
|
|
cmp_widget_cfg(const void *a, const void *b)
|
|
|
|
{
|
2007-12-16 08:41:10 +01:00
|
|
|
if (((cfg_t*)a)->line < ((cfg_t*)b)->line)
|
|
|
|
return -1;
|
2007-12-16 13:22:13 +01:00
|
|
|
|
|
|
|
if (((cfg_t*)a)->line > ((cfg_t*)b)->line)
|
2007-12-16 08:41:10 +01:00
|
|
|
return 1;
|
2007-12-16 13:22:13 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-12-16 08:41:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
|
|
|
|
{
|
|
|
|
cfg_t* widgets, *wptr;
|
|
|
|
Widget *widget = NULL;
|
2007-12-17 08:08:06 +01:00
|
|
|
unsigned int i, j, numwidgets = 0;
|
2007-12-16 09:34:33 +01:00
|
|
|
WidgetConstructor *widget_new;
|
2007-12-16 08:41:10 +01:00
|
|
|
|
2007-12-17 08:08:06 +01:00
|
|
|
for(i = 0; WidgetList[i].name; i++)
|
|
|
|
numwidgets += cfg_size(cfg_statusbar, WidgetList[i].name);
|
|
|
|
|
2007-12-16 08:41:10 +01:00
|
|
|
widgets = p_new(cfg_t, numwidgets);
|
|
|
|
wptr = widgets;
|
|
|
|
|
2007-12-17 08:08:06 +01:00
|
|
|
for(i = 0; WidgetList[i].name; i++)
|
|
|
|
for (j = 0; j < cfg_size(cfg_statusbar, WidgetList[i].name); j++)
|
2007-12-16 08:41:10 +01:00
|
|
|
{
|
|
|
|
memcpy(wptr,
|
2007-12-17 08:08:06 +01:00
|
|
|
cfg_getnsec(cfg_statusbar, WidgetList[i].name, j),
|
2007-12-16 08:41:10 +01:00
|
|
|
sizeof(cfg_t));
|
|
|
|
wptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(widgets, numwidgets, sizeof(cfg_t), cmp_widget_cfg);
|
|
|
|
|
2007-12-22 16:25:22 +01:00
|
|
|
for (i = 0; i < numwidgets; i++)
|
|
|
|
{
|
2007-12-17 10:57:17 +01:00
|
|
|
wptr = widgets + i;
|
|
|
|
widget_new = name_func_lookup(cfg_name(wptr), WidgetList);
|
2007-12-27 15:49:00 +01:00
|
|
|
if(widget_new)
|
|
|
|
{
|
2007-12-22 16:25:22 +01:00
|
|
|
if(!widget)
|
2007-12-27 15:49:00 +01:00
|
|
|
statusbar->widgets = widget = widget_new(statusbar, wptr);
|
2007-12-16 08:41:10 +01:00
|
|
|
else
|
|
|
|
{
|
2007-12-17 10:57:17 +01:00
|
|
|
widget->next = widget_new(statusbar, wptr);
|
2007-12-16 08:41:10 +01:00
|
|
|
widget = widget->next;
|
|
|
|
}
|
2007-12-27 15:49:00 +01:00
|
|
|
widget->buttons = parse_mouse_bindings(wptr, "mouse", a_strcmp(cfg_name(wptr), "taglist"));
|
|
|
|
}
|
2007-12-16 08:41:10 +01:00
|
|
|
else
|
|
|
|
warn("Ignoring unknown widget: %s.\n", cfg_name(widgets + i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-27 23:18:50 +01:00
|
|
|
static void
|
|
|
|
config_parse_screen(cfg_t *cfg, int screen)
|
|
|
|
{
|
|
|
|
char buf[2];
|
|
|
|
const char *tmp;
|
|
|
|
Layout *layout = NULL;
|
|
|
|
Tag *tag = NULL;
|
2007-12-30 21:00:34 +01:00
|
|
|
Statusbar *statusbar = NULL;
|
|
|
|
cfg_t *cfg_general, *cfg_colors, *cfg_screen, *cfg_tags,
|
2007-12-27 23:18:50 +01:00
|
|
|
*cfg_layouts, *cfg_padding, *cfgsectmp;
|
|
|
|
VirtScreen *virtscreen = &globalconf.screens[screen];
|
|
|
|
unsigned int i;
|
2008-01-02 17:41:03 +01:00
|
|
|
int phys_screen = get_phys_screen(screen);
|
2007-12-27 23:18:50 +01:00
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", screen);
|
|
|
|
cfg_screen = cfg_gettsec(cfg, "screen", buf);
|
|
|
|
if(!cfg_screen)
|
|
|
|
cfg_screen = cfg_getsec(cfg, "screen");
|
|
|
|
|
|
|
|
if(!cfg_screen)
|
|
|
|
{
|
|
|
|
warn("parsing configuration file failed, no screen section found\n");
|
|
|
|
cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);
|
|
|
|
cfg_screen = cfg_getsec(cfg, "screen");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get screen specific sections */
|
|
|
|
cfg_tags = cfg_getsec(cfg_screen, "tags");
|
|
|
|
cfg_colors = cfg_getsec(cfg_screen, "colors");
|
|
|
|
cfg_general = cfg_getsec(cfg_screen, "general");
|
|
|
|
cfg_layouts = cfg_getsec(cfg_screen, "layouts");
|
|
|
|
cfg_padding = cfg_getsec(cfg_screen, "padding");
|
|
|
|
|
|
|
|
|
|
|
|
/* General section */
|
|
|
|
virtscreen->borderpx = cfg_getint(cfg_general, "border");
|
|
|
|
virtscreen->snap = cfg_getint(cfg_general, "snap");
|
|
|
|
virtscreen->resize_hints = cfg_getbool(cfg_general, "resize_hints");
|
|
|
|
virtscreen->opacity_unfocused = cfg_getint(cfg_general, "opacity_unfocused");
|
|
|
|
virtscreen->focus_move_pointer = cfg_getbool(cfg_general, "focus_move_pointer");
|
|
|
|
virtscreen->allow_lower_floats = cfg_getbool(cfg_general, "allow_lower_floats");
|
2008-01-04 14:40:26 +01:00
|
|
|
virtscreen->sloppy_focus = cfg_getbool(cfg_general, "sloppy_focus");
|
2008-01-04 17:53:28 +01:00
|
|
|
virtscreen->new_become_master = cfg_getbool(cfg_general, "new_become_master");
|
2007-12-27 23:18:50 +01:00
|
|
|
virtscreen->font = XftFontOpenName(globalconf.display,
|
2008-01-02 17:41:03 +01:00
|
|
|
phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_general, "font"));
|
|
|
|
if(!virtscreen->font)
|
|
|
|
eprint("awesome: cannot init font\n");
|
|
|
|
|
|
|
|
/* Colors */
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_normal[ColBorder] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "normal_border"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_normal[ColBG] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "normal_bg"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_normal[ColFG] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "normal_fg"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_selected[ColBorder] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "focus_border"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_selected[ColBG] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "focus_bg"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_selected[ColFG] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "focus_fg"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_urgent[ColBG] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "urgent_bg"));
|
2008-01-02 17:41:03 +01:00
|
|
|
virtscreen->colors_urgent[ColFG] = initxcolor(phys_screen,
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_getstr(cfg_colors, "urgent_fg"));
|
|
|
|
|
|
|
|
/* Statusbar */
|
|
|
|
|
2007-12-30 21:00:34 +01:00
|
|
|
if(cfg_size(cfg_screen, "statusbar"))
|
|
|
|
{
|
|
|
|
virtscreen->statusbar = statusbar = p_new(Statusbar, 1);
|
|
|
|
for(i = 0; i < cfg_size(cfg_screen, "statusbar"); i++)
|
|
|
|
{
|
|
|
|
cfgsectmp = cfg_getnsec(cfg_screen, "statusbar", i);
|
|
|
|
statusbar->position = statusbar->dposition =
|
|
|
|
statusbar_get_position_from_str(cfg_getstr(cfgsectmp, "position"));
|
|
|
|
statusbar->height = cfg_getint(cfgsectmp, "height");
|
|
|
|
statusbar->width = cfg_getint(cfgsectmp, "width");
|
|
|
|
statusbar->name = a_strdup(cfg_title(cfgsectmp));
|
|
|
|
create_widgets(cfgsectmp, statusbar);
|
|
|
|
|
|
|
|
if(i < cfg_size(cfg_screen, "statusbar") - 1)
|
|
|
|
statusbar = statusbar->next = p_new(Statusbar, 1);
|
|
|
|
}
|
|
|
|
}
|
2007-12-27 23:18:50 +01:00
|
|
|
|
|
|
|
/* Layouts */
|
2007-12-27 23:28:33 +01:00
|
|
|
virtscreen->layouts = layout = p_new(Layout, 1);
|
2007-12-27 23:18:50 +01:00
|
|
|
if(cfg_size(cfg_layouts, "layout"))
|
|
|
|
for(i = 0; i < cfg_size(cfg_layouts, "layout"); i++)
|
|
|
|
{
|
|
|
|
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
|
|
|
|
layout->arrange = name_func_lookup(cfg_title(cfgsectmp), LayoutsList);
|
|
|
|
if(!layout->arrange)
|
|
|
|
{
|
|
|
|
warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp));
|
|
|
|
layout->image = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
layout->image = a_strdup(cfg_getstr(cfgsectmp, "image"));
|
|
|
|
|
|
|
|
if(i < cfg_size(cfg_layouts, "layout") - 1)
|
|
|
|
layout = layout->next = p_new(Layout, 1);
|
|
|
|
}
|
|
|
|
else
|
2007-12-27 23:28:33 +01:00
|
|
|
{
|
2007-12-30 21:00:34 +01:00
|
|
|
warn("no default layout available\n");
|
2007-12-27 23:28:33 +01:00
|
|
|
layout->arrange = layout_tile;
|
|
|
|
}
|
2007-12-27 23:18:50 +01:00
|
|
|
|
|
|
|
/* Tags */
|
2007-12-27 23:28:33 +01:00
|
|
|
virtscreen->tags = tag = p_new(Tag, 1);
|
2007-12-27 23:18:50 +01:00
|
|
|
if(cfg_size(cfg_tags, "tag"))
|
|
|
|
for(i = 0; i < cfg_size(cfg_tags, "tag"); i++)
|
|
|
|
{
|
|
|
|
cfgsectmp = cfg_getnsec(cfg_tags, "tag", i);
|
|
|
|
tag->name = a_strdup(cfg_title(cfgsectmp));
|
|
|
|
tag->selected = False;
|
|
|
|
tag->was_selected = False;
|
|
|
|
tmp = cfg_getstr(cfgsectmp, "layout");
|
|
|
|
for(layout = virtscreen->layouts;
|
|
|
|
layout && layout->arrange != name_func_lookup(tmp, LayoutsList); layout = layout->next);
|
|
|
|
if(!layout)
|
|
|
|
tag->layout = virtscreen->layouts;
|
|
|
|
else
|
|
|
|
tag->layout = layout;
|
|
|
|
tag->mwfact = cfg_getfloat(cfgsectmp, "mwfact");
|
|
|
|
tag->nmaster = cfg_getint(cfgsectmp, "nmaster");
|
|
|
|
tag->ncol = cfg_getint(cfgsectmp, "ncol");
|
|
|
|
|
|
|
|
if(i < cfg_size(cfg_tags, "tag") - 1)
|
|
|
|
tag = tag->next = p_new(Tag, 1);
|
|
|
|
else
|
|
|
|
tag->next = NULL;
|
|
|
|
}
|
|
|
|
else
|
2007-12-27 23:28:33 +01:00
|
|
|
{
|
|
|
|
warn("fatal: no tags found in configuration file\n");
|
|
|
|
tag->name = a_strdup("default");
|
|
|
|
tag->layout = virtscreen->layouts;
|
|
|
|
tag->nmaster = 1;
|
|
|
|
tag->ncol = 1;
|
|
|
|
tag->mwfact = 0.5;
|
|
|
|
}
|
2007-12-27 23:18:50 +01:00
|
|
|
|
2008-01-02 17:41:03 +01:00
|
|
|
ewmh_update_net_numbers_of_desktop(phys_screen);
|
|
|
|
ewmh_update_net_current_desktop(phys_screen);
|
|
|
|
ewmh_update_net_desktop_names(phys_screen);
|
2007-12-27 23:18:50 +01:00
|
|
|
|
|
|
|
/* select first tag by default */
|
|
|
|
virtscreen->tags[0].selected = True;
|
|
|
|
virtscreen->tags[0].was_selected = True;
|
|
|
|
|
|
|
|
/* padding */
|
|
|
|
virtscreen->padding.top = cfg_getint(cfg_padding, "top");
|
|
|
|
virtscreen->padding.bottom = cfg_getint(cfg_padding, "bottom");
|
|
|
|
virtscreen->padding.left = cfg_getint(cfg_padding, "left");
|
|
|
|
virtscreen->padding.right = cfg_getint(cfg_padding, "right");
|
|
|
|
}
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/** Parse configuration file and initialize some stuff
|
2007-12-19 04:26:20 +01:00
|
|
|
* \param confpatharg Path to configuration file
|
2007-09-05 20:15:00 +02:00
|
|
|
*/
|
|
|
|
void
|
2007-12-16 13:22:13 +01:00
|
|
|
config_parse(const char *confpatharg)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-10-08 18:45:05 +02:00
|
|
|
static cfg_opt_t general_opts[] =
|
|
|
|
{
|
|
|
|
CFG_INT((char *) "border", 1, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "snap", 8, CFGF_NONE),
|
2007-12-13 10:16:41 +01:00
|
|
|
CFG_BOOL((char *) "resize_hints", cfg_true, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_INT((char *) "opacity_unfocused", 100, CFGF_NONE),
|
|
|
|
CFG_BOOL((char *) "focus_move_pointer", cfg_false, CFGF_NONE),
|
2007-10-12 16:03:18 +02:00
|
|
|
CFG_BOOL((char *) "allow_lower_floats", cfg_false, CFGF_NONE),
|
2008-01-04 14:40:26 +01:00
|
|
|
CFG_BOOL((char *) "sloppy_focus", cfg_true, CFGF_NONE),
|
2008-01-04 17:53:28 +01:00
|
|
|
CFG_BOOL((char *) "new_become_master", cfg_true, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
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),
|
2007-12-23 15:16:10 +01:00
|
|
|
CFG_STR((char *) "urgent_bg", (char *) "#ff0000", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "urgent_fg", (char *) "#ffffff", CFGF_NONE),
|
2007-10-15 16:27:48 +02:00
|
|
|
CFG_STR((char *) "tab_border", (char *) "#ff0000", CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
2007-12-27 15:49:00 +01:00
|
|
|
static cfg_opt_t mouse_taglist_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "button", (char *) "None", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
|
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t mouse_generic_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "button", (char *) "None", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "arg", NULL, CFGF_NONE),
|
|
|
|
CFG_END()
|
|
|
|
};
|
2007-12-15 18:21:02 +01:00
|
|
|
static cfg_opt_t widget_opts[] =
|
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2007-12-27 15:49:00 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t widget_taglist_opts[] =
|
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2007-12-27 15:49:00 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_taglist_opts, CFGF_MULTI),
|
2007-12-15 18:21:02 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
2007-12-22 15:37:43 +01:00
|
|
|
static cfg_opt_t widget_iconbox_opts[] =
|
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2007-12-27 15:49:00 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
2007-12-22 15:37:43 +01:00
|
|
|
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
2008-01-02 14:59:15 +01:00
|
|
|
CFG_BOOL((char *) "resize", cfg_true, CFGF_NONE),
|
2007-12-22 15:37:43 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
2008-01-03 12:39:28 +01:00
|
|
|
static cfg_opt_t widget_textbox_opts[] =
|
2007-12-17 08:08:06 +01:00
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2007-12-27 15:49:00 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
2007-12-30 14:49:03 +01:00
|
|
|
CFG_INT((char *) "width", 0, CFGF_NONE),
|
2007-12-27 00:16:08 +01:00
|
|
|
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
|
2007-12-19 03:20:21 +01:00
|
|
|
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
2007-12-29 15:47:28 +01:00
|
|
|
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
|
2008-01-03 16:02:41 +01:00
|
|
|
CFG_STR((char *) "align", (char *) "center", CFGF_NONE),
|
2007-12-17 08:08:06 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
2008-01-03 12:39:28 +01:00
|
|
|
static cfg_opt_t widget_focustitle_opts[] =
|
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
|
|
|
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
|
2008-01-03 16:04:16 +01:00
|
|
|
CFG_STR((char *) "align", (char *) "left", CFGF_NONE),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t widget_tasklist_opts[] =
|
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
|
|
|
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "focus_fg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "focus_bg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
|
2008-01-03 16:05:39 +01:00
|
|
|
CFG_STR((char *) "align", (char *) "left", CFGF_NONE),
|
2008-01-03 19:21:36 +01:00
|
|
|
CFG_BOOL((char *) "show_icons", cfg_true, CFGF_NONE),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
2008-01-06 18:23:56 +01:00
|
|
|
static cfg_opt_t widget_graph_opts[] =
|
|
|
|
{
|
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
|
|
|
CFG_INT((char *) "width", 100, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "padding_left", 3, CFGF_NONE),
|
|
|
|
CFG_FLOAT((char *) "height", 0.67, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "bordercolor", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_END()
|
|
|
|
};
|
2008-01-01 16:23:28 +01:00
|
|
|
static cfg_opt_t widget_progressbar_bar_opts[] =
|
2008-01-01 15:33:30 +01:00
|
|
|
{
|
|
|
|
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
|
2008-01-06 18:23:56 +01:00
|
|
|
CFG_STR((char *) "bordercolor", (char *) NULL, CFGF_NONE),
|
2008-01-01 15:33:30 +01:00
|
|
|
};
|
2007-12-23 14:27:56 +01:00
|
|
|
static cfg_opt_t widget_progressbar_opts[] =
|
|
|
|
{
|
2008-01-05 13:01:40 +01:00
|
|
|
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
2007-12-27 15:49:00 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
2008-01-01 16:23:28 +01:00
|
|
|
CFG_SEC((char *) "bar", widget_progressbar_bar_opts, CFGF_MULTI),
|
|
|
|
CFG_INT((char *) "width", 100, CFGF_NONE),
|
2008-01-01 15:33:30 +01:00
|
|
|
CFG_INT((char *) "gap", 2, CFGF_NONE),
|
2008-01-06 18:23:56 +01:00
|
|
|
CFG_INT((char *) "padding_left", 3, CFGF_NONE),
|
2008-01-01 15:33:30 +01:00
|
|
|
CFG_FLOAT((char *) "height", 0.67, CFGF_NONE),
|
2007-12-23 14:27:56 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
2007-10-08 18:45:05 +02:00
|
|
|
static cfg_opt_t statusbar_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR((char *) "position", (char *) "top", CFGF_NONE),
|
2007-12-30 18:54:17 +01:00
|
|
|
CFG_INT((char *) "height", 0, CFGF_NONE),
|
2007-12-30 18:55:46 +01:00
|
|
|
CFG_INT((char *) "width", 0, CFGF_NONE),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_SEC((char *) "textbox", widget_textbox_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2007-12-30 18:36:18 +01:00
|
|
|
CFG_SEC((char *) "taglist", widget_taglist_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_SEC((char *) "focustitle", widget_focustitle_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2007-12-30 18:36:18 +01:00
|
|
|
CFG_SEC((char *) "layoutinfo", widget_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
|
|
|
CFG_SEC((char *) "iconbox", widget_iconbox_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
|
|
|
CFG_SEC((char *) "netwmicon", widget_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
|
|
|
CFG_SEC((char *) "progressbar", widget_progressbar_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2008-01-06 18:23:56 +01:00
|
|
|
CFG_SEC((char *) "graph", widget_graph_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2008-01-03 12:39:28 +01:00
|
|
|
CFG_SEC((char *) "tasklist", widget_tasklist_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t tag_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR((char *) "layout", (char *) "tile", CFGF_NONE),
|
2007-11-11 11:48:26 +01:00
|
|
|
CFG_FLOAT((char *) "mwfact", 0.5, CFGF_NONE),
|
2007-11-11 11:53:10 +01:00
|
|
|
CFG_INT((char *) "nmaster", 1, CFGF_NONE),
|
2007-11-11 11:55:20 +01:00
|
|
|
CFG_INT((char *) "ncol", 1, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t tags_opts[] =
|
|
|
|
{
|
2007-12-30 18:38:05 +01:00
|
|
|
CFG_SEC((char *) "tag", tag_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t layout_opts[] =
|
|
|
|
{
|
2007-12-27 00:13:44 +01:00
|
|
|
CFG_STR((char *) "image", NULL, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
|
|
|
static cfg_opt_t layouts_opts[] =
|
|
|
|
{
|
|
|
|
CFG_SEC((char *) "layout", layout_opts, CFGF_TITLE | CFGF_MULTI),
|
|
|
|
CFG_END()
|
|
|
|
};
|
2007-11-27 23:03:55 +01:00
|
|
|
static cfg_opt_t padding_opts[] =
|
|
|
|
{
|
|
|
|
CFG_INT((char *) "top", 0, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "bottom", 0, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "right", 0, CFGF_NONE),
|
|
|
|
CFG_INT((char *) "left", 0, CFGF_NONE),
|
|
|
|
CFG_END()
|
|
|
|
};
|
2007-11-09 14:45:43 +01:00
|
|
|
static cfg_opt_t screen_opts[] =
|
|
|
|
{
|
2007-11-11 12:02:16 +01:00
|
|
|
CFG_SEC((char *) "general", general_opts, CFGF_NONE),
|
2007-12-30 21:00:34 +01:00
|
|
|
CFG_SEC((char *) "statusbar", statusbar_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2007-11-11 11:36:30 +01:00
|
|
|
CFG_SEC((char *) "tags", tags_opts, CFGF_NONE),
|
2007-11-11 11:58:58 +01:00
|
|
|
CFG_SEC((char *) "colors", colors_opts, CFGF_NONE),
|
2007-11-11 12:05:04 +01:00
|
|
|
CFG_SEC((char *) "layouts", layouts_opts, CFGF_NONE),
|
2007-11-27 23:03:55 +01:00
|
|
|
CFG_SEC((char *) "padding", padding_opts, CFGF_NONE),
|
2007-12-27 14:10:16 +01:00
|
|
|
CFG_END()
|
2007-11-09 14:45:43 +01:00
|
|
|
};
|
2007-10-08 18:45:05 +02:00
|
|
|
static cfg_opt_t rule_opts[] =
|
|
|
|
{
|
2008-01-02 12:23:01 +01:00
|
|
|
CFG_STR((char *) "xproperty_name", NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "xproperty_value", NULL, CFGF_NONE),
|
2008-01-02 14:39:14 +01:00
|
|
|
CFG_STR((char *) "name", NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "tags", NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "icon", NULL, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_BOOL((char *) "float", cfg_false, CFGF_NONE),
|
2007-11-12 19:35:31 +01:00
|
|
|
CFG_INT((char *) "screen", RULE_NOSCREEN, CFGF_NONE),
|
2008-01-02 12:00:36 +01:00
|
|
|
CFG_BOOL((char *) "not_master", cfg_false, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
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()
|
|
|
|
};
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
static cfg_opt_t keylist_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR_LIST((char *) "modkey", (char *) "{Mod4}", CFGF_NONE),
|
|
|
|
CFG_STR_LIST((char *) "keylist", (char *) NULL, CFGF_NONE),
|
|
|
|
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
|
|
|
|
CFG_STR_LIST((char *) "arglist", NULL, CFGF_NONE),
|
|
|
|
CFG_END()
|
|
|
|
};
|
2007-10-08 18:45:05 +02:00
|
|
|
static cfg_opt_t keys_opts[] =
|
|
|
|
{
|
|
|
|
CFG_SEC((char *) "key", key_opts, CFGF_MULTI),
|
Add a way to define key bindings in bulk, like this:
keylist
{
modkey = {"Mod4"}
command = "client_tag"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
This patch also modifies the example awesomerc to use the new syntax. Should
be fully backwards compatible.
2007-12-12 01:24:27 +01:00
|
|
|
CFG_SEC((char *) "keylist", keylist_opts, CFGF_MULTI),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
2007-11-11 13:17:23 +01:00
|
|
|
static cfg_opt_t mouse_opts[] =
|
|
|
|
{
|
2007-11-12 10:53:48 +01:00
|
|
|
CFG_SEC((char *) "root", mouse_generic_opts, CFGF_MULTI),
|
2007-11-14 17:18:16 +01:00
|
|
|
CFG_SEC((char *) "client", mouse_generic_opts, CFGF_MULTI),
|
2007-11-11 13:17:23 +01:00
|
|
|
CFG_END()
|
|
|
|
};
|
2007-10-08 18:45:05 +02:00
|
|
|
static cfg_opt_t opts[] =
|
|
|
|
{
|
2007-12-30 18:38:05 +01:00
|
|
|
CFG_SEC((char *) "screen", screen_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_SEC((char *) "rules", rules_opts, CFGF_NONE),
|
|
|
|
CFG_SEC((char *) "keys", keys_opts, CFGF_NONE),
|
2007-11-11 13:17:23 +01:00
|
|
|
CFG_SEC((char *) "mouse", mouse_opts, CFGF_NONE),
|
2007-10-08 18:45:05 +02:00
|
|
|
CFG_END()
|
|
|
|
};
|
2007-12-27 23:18:50 +01:00
|
|
|
cfg_t *cfg, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp;
|
2007-12-14 19:02:38 +01:00
|
|
|
int ret, screen;
|
|
|
|
unsigned int i = 0;
|
2007-12-27 23:18:50 +01:00
|
|
|
const char *homedir;
|
|
|
|
char *confpath;
|
2007-10-15 12:06:43 +02:00
|
|
|
ssize_t confpath_len;
|
2007-11-12 19:25:10 +01:00
|
|
|
Rule *rule = NULL;
|
2007-12-13 11:04:48 +01:00
|
|
|
FILE *defconfig = NULL;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-26 21:22:30 +02:00
|
|
|
if(confpatharg)
|
|
|
|
confpath = a_strdup(confpatharg);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
homedir = getenv("HOME");
|
|
|
|
confpath_len = a_strlen(homedir) + a_strlen(AWESOME_CONFIG_FILE) + 2;
|
|
|
|
confpath = p_new(char, confpath_len);
|
|
|
|
a_strcpy(confpath, confpath_len, homedir);
|
|
|
|
a_strcat(confpath, confpath_len, "/");
|
|
|
|
a_strcat(confpath, confpath_len, AWESOME_CONFIG_FILE);
|
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.configpath = a_strdup(confpath);
|
2007-11-08 11:22:25 +01:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
cfg = cfg_init(opts, CFGF_NONE);
|
|
|
|
|
2007-10-31 15:11:39 +01:00
|
|
|
ret = cfg_parse(cfg, confpath);
|
|
|
|
if(ret == CFG_FILE_ERROR)
|
2007-12-10 11:54:00 +01:00
|
|
|
{
|
2007-10-31 15:11:39 +01:00
|
|
|
perror("awesome: parsing configuration file failed");
|
2007-12-13 11:04:48 +01:00
|
|
|
if(!(defconfig = fopen(confpath, "w")))
|
|
|
|
perror("awesome: unable to create default configuration file");
|
2007-12-10 11:54:00 +01:00
|
|
|
}
|
2007-10-31 15:11:39 +01:00
|
|
|
else if(ret == CFG_PARSE_ERROR)
|
|
|
|
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
|
2008-01-05 09:24:43 +01:00
|
|
|
if(ret != CFG_SUCCESS) {
|
|
|
|
fprintf(stderr, "Using default compile-time configuration\n");
|
|
|
|
cfg_free(cfg);
|
|
|
|
cfg = cfg_init(opts, CFGF_NONE);
|
|
|
|
cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);
|
|
|
|
}
|
2007-10-03 17:26:14 +02:00
|
|
|
|
2007-11-09 14:45:43 +01:00
|
|
|
/* get the right screen section */
|
2007-12-18 09:02:08 +01:00
|
|
|
for(screen = 0; screen < get_screen_count(); screen++)
|
2007-12-27 23:18:50 +01:00
|
|
|
config_parse_screen(cfg, screen);
|
2007-09-06 21:53:45 +02:00
|
|
|
|
2007-12-11 20:56:51 +01:00
|
|
|
/* get general sections */
|
|
|
|
cfg_rules = cfg_getsec(cfg, "rules");
|
|
|
|
cfg_keys = cfg_getsec(cfg, "keys");
|
|
|
|
cfg_mouse = cfg_getsec(cfg, "mouse");
|
2007-09-18 22:49:34 +02:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Rules */
|
2007-11-12 19:25:10 +01:00
|
|
|
if(cfg_size(cfg_rules, "rule"))
|
2007-09-18 22:49:34 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.rules = rule = p_new(Rule, 1);
|
2007-12-14 19:02:38 +01:00
|
|
|
for(i = 0; i < cfg_size(cfg_rules, "rule"); i++)
|
2007-11-12 19:25:10 +01:00
|
|
|
{
|
2007-12-14 19:02:38 +01:00
|
|
|
cfgsectmp = cfg_getnsec(cfg_rules, "rule", i);
|
2008-01-02 12:44:18 +01:00
|
|
|
rule->prop_r = rules_compile_regex(cfg_getstr(cfgsectmp, "name"));
|
|
|
|
rule->tags_r = rules_compile_regex(cfg_getstr(cfgsectmp, "tags"));
|
|
|
|
rule->xprop = a_strdup(cfg_getstr(cfgsectmp, "xproperty_name"));
|
|
|
|
rule->xpropval_r = rules_compile_regex(cfg_getstr(cfgsectmp, "xproperty_value"));
|
2007-12-29 19:44:15 +01:00
|
|
|
rule->icon = a_strdup(cfg_getstr(cfgsectmp, "icon"));
|
2007-11-12 19:25:10 +01:00
|
|
|
rule->isfloating = cfg_getbool(cfgsectmp, "float");
|
|
|
|
rule->screen = cfg_getint(cfgsectmp, "screen");
|
2008-01-02 12:00:36 +01:00
|
|
|
rule->not_master = cfg_getbool(cfgsectmp, "not_master");
|
2007-12-18 09:02:08 +01:00
|
|
|
if(rule->screen >= get_screen_count())
|
2007-11-12 19:25:10 +01:00
|
|
|
rule->screen = 0;
|
2007-11-13 22:29:33 +01:00
|
|
|
|
2007-12-14 19:02:38 +01:00
|
|
|
if(i < cfg_size(cfg_rules, "rule") - 1)
|
2007-12-14 17:57:05 +01:00
|
|
|
rule = rule->next = p_new(Rule, 1);
|
2007-11-13 22:29:33 +01:00
|
|
|
else
|
|
|
|
rule->next = NULL;
|
2007-11-12 19:25:10 +01:00
|
|
|
}
|
2007-09-18 22:49:34 +02:00
|
|
|
}
|
2007-11-12 19:25:10 +01:00
|
|
|
else
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.rules = NULL;
|
2007-09-18 22:49:34 +02:00
|
|
|
|
2007-11-12 10:53:48 +01:00
|
|
|
/* Mouse: root window click bindings */
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.buttons.root = parse_mouse_bindings(cfg_mouse, "root", True);
|
2007-11-12 10:53:48 +01:00
|
|
|
|
2007-11-14 17:18:16 +01:00
|
|
|
/* Mouse: client windows click bindings */
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.buttons.client = parse_mouse_bindings(cfg_mouse, "client", True);
|
2007-11-14 17:18:16 +01:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Keys */
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.numlockmask = get_numlockmask(globalconf.display);
|
2007-11-12 17:22:40 +01:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
globalconf.keys = section_keys(cfg_keys);
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-12-13 11:04:48 +01:00
|
|
|
if(defconfig)
|
|
|
|
{
|
|
|
|
cfg_print(cfg, defconfig);
|
|
|
|
fclose(defconfig);
|
|
|
|
}
|
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Free! Like a river! */
|
|
|
|
cfg_free(cfg);
|
2007-09-05 20:15:00 +02:00
|
|
|
p_delete(&confpath);
|
|
|
|
}
|
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|