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
|
|
|
*
|
|
|
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
/**
|
|
|
|
* \defgroup ui_callback
|
|
|
|
*/
|
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
#include <confuse.h>
|
2007-09-05 20:15:00 +02:00
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
2007-09-15 15:26:51 +02:00
|
|
|
#include "util.h"
|
2007-10-15 11:53:10 +02:00
|
|
|
#include "awesome.h"
|
2007-09-24 14:21:49 +02:00
|
|
|
#include "screen.h"
|
2007-10-12 17:10:36 +02:00
|
|
|
#include "draw.h"
|
2007-10-15 11:53:10 +02:00
|
|
|
#include "tag.h"
|
2007-11-13 21:40:33 +01:00
|
|
|
#include "rules.h"
|
2007-10-15 11:53:10 +02:00
|
|
|
#include "statusbar.h"
|
|
|
|
#include "layout.h"
|
2007-11-13 22:57:57 +01:00
|
|
|
#include "mouse.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/tile.h"
|
|
|
|
#include "layouts/floating.h"
|
2007-10-12 17:10:36 +02:00
|
|
|
#include "layouts/max.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-10-12 13:09:59 +02:00
|
|
|
#define AWESOME_CONFIG_FILE ".awesomerc"
|
|
|
|
|
2007-10-01 19:22:57 +02:00
|
|
|
static XColor initxcolor(Display *, int, const char *);
|
2007-09-05 20:15:00 +02:00
|
|
|
static unsigned int get_numlockmask(Display *);
|
|
|
|
|
|
|
|
/** 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-09-05 20:15:00 +02:00
|
|
|
/** List of available UI bindable callbacks and functions */
|
2007-10-12 17:10:36 +02:00
|
|
|
const NameFuncLink UicbList[] = {
|
2007-09-05 20:15:00 +02:00
|
|
|
/* util.c */
|
2007-09-12 18:19:28 +02:00
|
|
|
{"spawn", uicb_spawn},
|
2007-09-28 13:39:46 +02:00
|
|
|
{"exec", uicb_exec},
|
2007-09-05 20:15:00 +02:00
|
|
|
/* client.c */
|
2007-11-14 17:50:16 +01:00
|
|
|
{"client_kill", uicb_client_kill},
|
2007-11-14 17:51:22 +01:00
|
|
|
{"client_moveresize", uicb_client_moveresize},
|
2007-11-14 17:52:49 +01:00
|
|
|
{"client_settrans", uicb_client_settrans},
|
2007-09-18 23:36:52 +02:00
|
|
|
{"setborder", uicb_setborder},
|
2007-11-14 17:54:22 +01:00
|
|
|
{"client_swapnext", uicb_client_swapnext},
|
|
|
|
{"client_swapprev", uicb_client_swapprev},
|
2007-09-05 20:15:00 +02:00
|
|
|
/* tag.c */
|
2007-11-14 17:56:16 +01:00
|
|
|
{"client_tag", uicb_client_tag},
|
2007-09-05 20:15:00 +02:00
|
|
|
{"togglefloating", uicb_togglefloating},
|
|
|
|
{"toggleview", uicb_toggleview},
|
|
|
|
{"toggletag", uicb_toggletag},
|
|
|
|
{"view", uicb_view},
|
2007-09-20 22:24:52 +02:00
|
|
|
{"view_tag_prev_selected", uicb_tag_prev_selected},
|
|
|
|
{"view_tag_previous", uicb_tag_viewprev},
|
|
|
|
{"view_tag_next", uicb_tag_viewnext},
|
2007-09-05 20:15:00 +02:00
|
|
|
/* layout.c */
|
|
|
|
{"setlayout", uicb_setlayout},
|
|
|
|
{"focusnext", uicb_focusnext},
|
2007-10-12 17:10:36 +02:00
|
|
|
{"focusprev", uicb_focusprev},
|
2007-09-05 20:15:00 +02:00
|
|
|
{"togglemax", uicb_togglemax},
|
|
|
|
{"toggleverticalmax", uicb_toggleverticalmax},
|
|
|
|
{"togglehorizontalmax", uicb_togglehorizontalmax},
|
|
|
|
{"zoom", uicb_zoom},
|
|
|
|
/* layouts/tile.c */
|
|
|
|
{"setmwfact", uicb_setmwfact},
|
2007-09-11 15:53:03 +02:00
|
|
|
{"setnmaster", uicb_setnmaster},
|
2007-10-08 18:45:05 +02:00
|
|
|
{"setncol", uicb_setncol},
|
2007-09-24 14:21:49 +02:00
|
|
|
/* screen.c */
|
|
|
|
{"focusnextscreen", uicb_focusnextscreen},
|
|
|
|
{"focusprevscreen", uicb_focusprevscreen},
|
2007-09-27 21:51:05 +02:00
|
|
|
{"movetoscreen", uicb_movetoscreen},
|
2007-09-10 12:06:54 +02:00
|
|
|
/* awesome.c */
|
2007-09-05 20:15:00 +02:00
|
|
|
{"quit", uicb_quit},
|
2007-09-15 15:34:28 +02:00
|
|
|
/* statusbar.c */
|
|
|
|
{"togglebar", uicb_togglebar},
|
2007-10-31 11:37:38 +01:00
|
|
|
/* config.c */
|
|
|
|
{"reloadconfig", uicb_reloadconfig},
|
2007-10-12 17:10:36 +02:00
|
|
|
{"setstatustext", uicb_setstatustext},
|
2007-11-13 22:57:57 +01:00
|
|
|
/* mouse.c */
|
2007-11-12 14:02:52 +01:00
|
|
|
{"movemouse", uicb_movemouse},
|
2007-11-12 14:06:59 +01:00
|
|
|
{"resizemouse", uicb_resizemouse},
|
2007-10-12 17:10:36 +02:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** 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},
|
2007-11-12 10:53:48 +01:00
|
|
|
{NULL, NoSymbol}
|
2007-10-12 17:10:36 +02:00
|
|
|
};
|
|
|
|
|
2007-11-11 15:40:01 +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-10-12 17:10:36 +02:00
|
|
|
/** List of available layouts and link between name and functions */
|
|
|
|
static const NameFuncLink LayoutsList[] =
|
|
|
|
{
|
|
|
|
{"tile", layout_tile},
|
|
|
|
{"tileleft", layout_tileleft},
|
|
|
|
{"max", layout_max},
|
|
|
|
{"floating", layout_floating},
|
2007-09-05 20:15:00 +02:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** 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)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
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-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
|
|
|
}
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
/** Parse configuration file and initialize some stuff
|
|
|
|
* \param disp Display ref
|
|
|
|
* \param scr Screen number
|
|
|
|
*/
|
|
|
|
void
|
2007-10-30 14:57:00 +01:00
|
|
|
parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
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),
|
|
|
|
CFG_BOOL((char *) "resize_hints", cfg_false, CFGF_NONE),
|
|
|
|
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),
|
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-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()
|
|
|
|
};
|
|
|
|
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),
|
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[] =
|
|
|
|
{
|
|
|
|
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_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-11-09 14:45:43 +01:00
|
|
|
CFG_SEC((char *) "statusbar", statusbar_opts, CFGF_NONE),
|
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-09 14:45:43 +01:00
|
|
|
};
|
2007-10-08 18:45:05 +02:00
|
|
|
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),
|
2007-11-12 19:35:31 +01:00
|
|
|
CFG_INT((char *) "screen", RULE_NOSCREEN, 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()
|
|
|
|
};
|
|
|
|
static cfg_opt_t keys_opts[] =
|
|
|
|
{
|
|
|
|
CFG_SEC((char *) "key", key_opts, CFGF_MULTI),
|
|
|
|
CFG_END()
|
|
|
|
};
|
2007-11-11 15:40:01 +01:00
|
|
|
static cfg_opt_t mouse_tag_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "button", (char *) "None", CFGF_NONE),
|
|
|
|
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
|
|
|
|
};
|
2007-11-11 16:48:19 +01:00
|
|
|
static cfg_opt_t mouse_generic_opts[] =
|
2007-11-11 15:55:13 +01:00
|
|
|
{
|
|
|
|
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),
|
|
|
|
};
|
2007-11-11 13:17:23 +01:00
|
|
|
static cfg_opt_t mouse_opts[] =
|
|
|
|
{
|
|
|
|
CFG_STR((char *) "modkey", (char *) "Mod4", CFGF_NONE),
|
2007-11-11 15:40:01 +01:00
|
|
|
CFG_SEC((char *) "tag", mouse_tag_opts, CFGF_MULTI),
|
2007-11-11 16:48:19 +01:00
|
|
|
CFG_SEC((char *) "layout", mouse_generic_opts, CFGF_MULTI),
|
|
|
|
CFG_SEC((char *) "title", mouse_generic_opts, CFGF_MULTI),
|
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-11-09 14:45:43 +01:00
|
|
|
CFG_SEC((char *) "screen", screen_opts, CFGF_TITLE | CFGF_MULTI),
|
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-11-09 14:45:43 +01:00
|
|
|
cfg_t *cfg, *cfg_general, *cfg_colors, *cfg_screen, *cfg_statusbar,
|
2007-11-11 13:17:23 +01:00
|
|
|
*cfg_tags, *cfg_layouts, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp;
|
2007-10-31 15:11:39 +01:00
|
|
|
int i = 0, k = 0, ret;
|
2007-11-12 17:22:40 +01:00
|
|
|
unsigned int j = 0, l = 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
const char *tmp, *homedir;
|
2007-11-09 14:45:43 +01:00
|
|
|
char *confpath, buf[2];
|
2007-10-15 12:06:43 +02:00
|
|
|
ssize_t confpath_len;
|
2007-11-12 17:22:40 +01:00
|
|
|
Key *key = NULL;
|
2007-11-12 19:25:10 +01:00
|
|
|
Rule *rule = 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-11-08 11:22:25 +01:00
|
|
|
awesomeconf->configpath = a_strdup(confpath);
|
|
|
|
|
2007-10-29 17:16:33 +01:00
|
|
|
a_strcpy(awesomeconf->statustext, sizeof(awesomeconf->statustext), "awesome-" VERSION " (" RELEASE ")");
|
2007-09-26 20:16:04 +02:00
|
|
|
|
2007-10-30 14:57:00 +01:00
|
|
|
awesomeconf->phys_screen = get_phys_screen(awesomeconf->display, awesomeconf->screen);
|
2007-09-16 23:12:53 +02: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)
|
|
|
|
perror("awesome: parsing configuration file failed");
|
|
|
|
else if(ret == CFG_PARSE_ERROR)
|
|
|
|
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
|
2007-10-03 17:26:14 +02:00
|
|
|
|
2007-11-09 14:45:43 +01:00
|
|
|
/* get the right screen section */
|
|
|
|
snprintf(buf, sizeof(buf), "%d", awesomeconf->screen);
|
|
|
|
cfg_screen = cfg_gettsec(cfg, "screen", buf);
|
|
|
|
if(!cfg_screen)
|
|
|
|
cfg_screen = cfg_getsec(cfg, "screen");
|
|
|
|
|
|
|
|
/* get screen specific sections */
|
|
|
|
cfg_statusbar = cfg_getsec(cfg_screen, "statusbar");
|
2007-11-11 11:36:30 +01:00
|
|
|
cfg_tags = cfg_getsec(cfg_screen, "tags");
|
2007-11-11 11:58:58 +01:00
|
|
|
cfg_colors = cfg_getsec(cfg_screen, "colors");
|
2007-11-11 12:02:16 +01:00
|
|
|
cfg_general = cfg_getsec(cfg_screen, "general");
|
2007-11-11 12:05:04 +01:00
|
|
|
cfg_layouts = cfg_getsec(cfg_screen, "layouts");
|
2007-11-09 14:45:43 +01:00
|
|
|
|
|
|
|
/* get general sections */
|
2007-10-08 18:45:05 +02:00
|
|
|
cfg_rules = cfg_getsec(cfg, "rules");
|
|
|
|
cfg_keys = cfg_getsec(cfg, "keys");
|
2007-11-11 13:17:23 +01:00
|
|
|
cfg_mouse = cfg_getsec(cfg, "mouse");
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* General section */
|
2007-10-01 19:22:57 +02:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
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");
|
2007-10-12 16:03:18 +02:00
|
|
|
awesomeconf->allow_lower_floats = cfg_getbool(cfg_general, "allow_lower_floats");
|
2007-10-30 14:57:00 +01:00
|
|
|
awesomeconf->font = XftFontOpenName(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_general, "font"));
|
2007-10-10 13:34:25 +02:00
|
|
|
if(!awesomeconf->font)
|
2007-10-01 19:22:57 +02:00
|
|
|
eprint("awesome: cannot init font\n");
|
2007-09-07 15:04:02 +02:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Colors */
|
2007-10-30 14:57:00 +01:00
|
|
|
awesomeconf->colors_normal[ColBorder] = initxcolor(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "normal_border"));
|
|
|
|
awesomeconf->colors_normal[ColBG] = initxcolor(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "normal_bg"));
|
|
|
|
awesomeconf->colors_normal[ColFG] = initxcolor(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "normal_fg"));
|
|
|
|
awesomeconf->colors_selected[ColBorder] = initxcolor(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "focus_border"));
|
|
|
|
awesomeconf->colors_selected[ColBG] = initxcolor(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "focus_bg"));
|
|
|
|
awesomeconf->colors_selected[ColFG] = initxcolor(awesomeconf->display, awesomeconf->phys_screen, cfg_getstr(cfg_colors, "focus_fg"));
|
2007-09-06 21:53:45 +02:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Statusbar */
|
|
|
|
tmp = cfg_getstr(cfg_statusbar, "position");
|
|
|
|
|
|
|
|
if(tmp && !a_strncmp(tmp, "off", 6))
|
2007-11-10 10:17:54 +01:00
|
|
|
awesomeconf->statusbar.dposition = BarOff;
|
2007-10-08 18:45:05 +02:00
|
|
|
else if(tmp && !a_strncmp(tmp, "bottom", 6))
|
2007-11-10 10:17:54 +01:00
|
|
|
awesomeconf->statusbar.dposition = BarBot;
|
2007-11-11 18:59:11 +01:00
|
|
|
else if(tmp && !a_strncmp(tmp, "right", 5))
|
|
|
|
awesomeconf->statusbar.dposition = BarRight;
|
|
|
|
else if(tmp && !a_strncmp(tmp, "left", 4))
|
|
|
|
awesomeconf->statusbar.dposition = BarLeft;
|
2007-09-10 16:11:57 +02:00
|
|
|
else
|
2007-11-10 10:17:54 +01:00
|
|
|
awesomeconf->statusbar.dposition = BarTop;
|
2007-10-08 18:45:05 +02:00
|
|
|
|
2007-11-10 10:17:54 +01:00
|
|
|
awesomeconf->statusbar.position = awesomeconf->statusbar.dposition;
|
2007-10-08 18:45:05 +02:00
|
|
|
|
|
|
|
/* Layouts */
|
|
|
|
awesomeconf->nlayouts = cfg_size(cfg_layouts, "layout");
|
|
|
|
awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts);
|
|
|
|
for(i = 0; i < awesomeconf->nlayouts; i++)
|
2007-09-06 21:53:45 +02:00
|
|
|
{
|
2007-10-08 18:45:05 +02:00
|
|
|
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
|
|
|
|
awesomeconf->layouts[i].arrange = name_func_lookup(cfg_title(cfgsectmp), LayoutsList);
|
|
|
|
if(!awesomeconf->layouts[i].arrange)
|
2007-09-10 16:11:57 +02:00
|
|
|
{
|
2007-10-08 18:45:05 +02:00
|
|
|
fprintf(stderr, "awesome: unknown layout #%d in configuration file\n", i);
|
|
|
|
awesomeconf->layouts[i].symbol = NULL;
|
|
|
|
continue;
|
2007-09-10 16:11:57 +02:00
|
|
|
}
|
2007-10-08 18:45:05 +02:00
|
|
|
awesomeconf->layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
|
2007-09-06 21:53:45 +02:00
|
|
|
}
|
|
|
|
|
2007-10-10 19:03:23 +02:00
|
|
|
if(!awesomeconf->nlayouts)
|
2007-09-10 16:11:57 +02:00
|
|
|
eprint("awesome: fatal: no default layout available\n");
|
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-11-12 19:25:10 +01:00
|
|
|
awesomeconf->rules = rule = p_new(Rule, 1);
|
|
|
|
for(j = 0; j < cfg_size(cfg_rules, "rule"); j++)
|
|
|
|
{
|
|
|
|
cfgsectmp = cfg_getnsec(cfg_rules, "rule", j);
|
|
|
|
rule->prop = a_strdup(cfg_getstr(cfgsectmp, "name"));
|
|
|
|
rule->tags = a_strdup(cfg_getstr(cfgsectmp, "tags"));
|
|
|
|
if(!a_strlen(rule->tags))
|
|
|
|
rule->tags = NULL;
|
|
|
|
rule->isfloating = cfg_getbool(cfgsectmp, "float");
|
|
|
|
rule->screen = cfg_getint(cfgsectmp, "screen");
|
|
|
|
if(rule->screen >= get_screen_count(awesomeconf->display))
|
|
|
|
rule->screen = 0;
|
2007-11-13 22:29:33 +01:00
|
|
|
|
|
|
|
if(j < cfg_size(cfg_rules, "rule") - 1)
|
|
|
|
{
|
|
|
|
rule->next = p_new(Rule, 1);
|
|
|
|
rule = rule->next;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
awesomeconf->rules = NULL;
|
2007-09-18 22:49:34 +02:00
|
|
|
|
2007-11-12 19:25:10 +01:00
|
|
|
compileregs(awesomeconf->rules);
|
2007-10-15 12:40:45 +02:00
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Tags */
|
|
|
|
awesomeconf->ntags = cfg_size(cfg_tags, "tag");
|
|
|
|
awesomeconf->tags = p_new(Tag, awesomeconf->ntags);
|
|
|
|
for(i = 0; i < awesomeconf->ntags; i++)
|
2007-09-26 20:16:04 +02:00
|
|
|
{
|
2007-10-08 18:45:05 +02:00
|
|
|
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;
|
2007-10-10 18:47:58 +02:00
|
|
|
tmp = cfg_getstr(cfgsectmp, "layout");
|
|
|
|
for(k = 0; k < awesomeconf->nlayouts; k++)
|
|
|
|
if(awesomeconf->layouts[k].arrange == name_func_lookup(tmp, LayoutsList))
|
|
|
|
break;
|
|
|
|
if(k == awesomeconf->nlayouts)
|
|
|
|
k = 0;
|
|
|
|
awesomeconf->tags[i].layout = &awesomeconf->layouts[k];
|
2007-11-11 11:48:26 +01:00
|
|
|
awesomeconf->tags[i].mwfact = cfg_getfloat(cfgsectmp, "mwfact");
|
2007-11-11 11:53:10 +01:00
|
|
|
awesomeconf->tags[i].nmaster = cfg_getint(cfgsectmp, "nmaster");
|
2007-11-11 11:55:20 +01:00
|
|
|
awesomeconf->tags[i].ncol = cfg_getint(cfgsectmp, "ncol");
|
2007-09-06 19:05:26 +02:00
|
|
|
}
|
|
|
|
|
2007-10-10 18:47:58 +02:00
|
|
|
|
2007-09-18 22:49:34 +02:00
|
|
|
if(!awesomeconf->ntags)
|
|
|
|
eprint("awesome: fatal: no tags found in configuration file\n");
|
|
|
|
|
2007-09-06 19:05:26 +02:00
|
|
|
/* select first tag by default */
|
2007-09-24 15:37:52 +02:00
|
|
|
awesomeconf->tags[0].selected = True;
|
|
|
|
awesomeconf->tags[0].was_selected = True;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-11-11 15:40:01 +01:00
|
|
|
/* Mouse */
|
|
|
|
if(!(awesomeconf->modkey = key_mask_lookup(cfg_getstr(cfg_mouse, "modkey"))))
|
|
|
|
awesomeconf->modkey = Mod4Mask;
|
|
|
|
|
|
|
|
/* Mouse: tags click bindings */
|
2007-11-12 13:21:28 +01:00
|
|
|
awesomeconf->buttons.tag = parse_mouse_bindings(cfg_mouse, "tag", False);
|
2007-11-11 15:40:01 +01:00
|
|
|
|
2007-11-11 16:01:49 +01:00
|
|
|
/* Mouse: layout click bindings */
|
2007-11-12 13:21:28 +01:00
|
|
|
awesomeconf->buttons.layout = parse_mouse_bindings(cfg_mouse, "layout", True);
|
2007-11-11 16:01:49 +01:00
|
|
|
|
2007-11-11 15:55:13 +01:00
|
|
|
/* Mouse: title click bindings */
|
2007-11-12 13:21:28 +01:00
|
|
|
awesomeconf->buttons.title = parse_mouse_bindings(cfg_mouse, "title", True);
|
2007-11-11 15:55:13 +01:00
|
|
|
|
2007-11-12 10:53:48 +01:00
|
|
|
/* Mouse: root window click bindings */
|
2007-11-12 13:21:28 +01:00
|
|
|
awesomeconf->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 */
|
|
|
|
awesomeconf->buttons.client = parse_mouse_bindings(cfg_mouse, "client", True);
|
|
|
|
|
2007-10-08 18:45:05 +02:00
|
|
|
/* Keys */
|
2007-10-30 14:57:00 +01:00
|
|
|
awesomeconf->numlockmask = get_numlockmask(awesomeconf->display);
|
2007-11-12 17:22:40 +01:00
|
|
|
|
|
|
|
if(cfg_size(cfg_keys, "key"))
|
2007-09-26 20:16:04 +02:00
|
|
|
{
|
2007-11-12 17:22:40 +01:00
|
|
|
awesomeconf->keys = key = p_new(Key, 1);
|
|
|
|
for(j = 0; j < cfg_size(cfg_keys, "key"); j++)
|
|
|
|
{
|
|
|
|
cfgsectmp = cfg_getnsec(cfg_keys, "key", j);
|
|
|
|
for(l = 0; l < cfg_size(cfgsectmp, "modkey"); l++)
|
|
|
|
key->mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", l));
|
|
|
|
key->keysym = XStringToKeysym(cfg_getstr(cfgsectmp, "key"));
|
|
|
|
key->func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), UicbList);
|
|
|
|
key->arg = a_strdup(cfg_getstr(cfgsectmp, "arg"));
|
|
|
|
|
|
|
|
if(j < cfg_size(cfg_keys, "key") - 1)
|
|
|
|
{
|
|
|
|
key->next = p_new(Key, 1);
|
|
|
|
key = key->next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
key->next = NULL;
|
|
|
|
}
|
2007-09-26 20:16:04 +02:00
|
|
|
}
|
2007-11-12 17:22:40 +01:00
|
|
|
else
|
|
|
|
awesomeconf->keys = NULL;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
get_numlockmask(Display *disp)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initialize color from X side
|
|
|
|
* \param colorstr Color code
|
|
|
|
* \param disp Display ref
|
|
|
|
* \param scr Screen number
|
|
|
|
* \return XColor pixel
|
|
|
|
*/
|
2007-10-01 19:22:57 +02:00
|
|
|
static XColor
|
|
|
|
initxcolor(Display *disp, int scr, const char *colstr)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XColor color;
|
2007-10-01 19:22:57 +02:00
|
|
|
if(!XAllocNamedColor(disp, DefaultColormap(disp, scr), colstr, &color, &color))
|
2007-09-18 22:49:34 +02:00
|
|
|
die("awesome: error, cannot allocate color '%s'\n", colstr);
|
2007-10-01 19:22:57 +02:00
|
|
|
return color;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-10-31 11:37:38 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
uicb_reloadconfig(awesome_config *awesomeconf,
|
2007-10-31 11:41:50 +01:00
|
|
|
const char *arg __attribute__ ((unused)))
|
2007-10-31 11:37:38 +01:00
|
|
|
{
|
|
|
|
int i, j, tag, screen, screen_count = get_screen_count(awesomeconf->display);
|
|
|
|
awesome_config *awesomeconf_first = &awesomeconf[-awesomeconf->screen];
|
|
|
|
int *old_ntags, old_c_ntags, new_c_ntags, **mapping;
|
|
|
|
char ***savetagnames;
|
2007-10-31 11:43:17 +01:00
|
|
|
Client ***savetagclientsel;
|
2007-11-08 11:22:25 +01:00
|
|
|
char *configpath = a_strdup(awesomeconf_first->configpath);
|
2007-11-08 11:23:04 +01:00
|
|
|
Bool ***savetagselected;
|
2007-10-31 11:37:38 +01:00
|
|
|
Bool *old_c_tags;
|
2007-10-31 11:41:50 +01:00
|
|
|
Client *c, *clients;
|
2007-10-31 11:37:38 +01:00
|
|
|
|
2007-10-31 11:41:50 +01:00
|
|
|
/* Save tag information */
|
|
|
|
savetagnames = p_new(char **, screen_count);
|
2007-10-31 11:43:17 +01:00
|
|
|
savetagclientsel = p_new(Client **, screen_count);
|
2007-11-08 11:23:04 +01:00
|
|
|
savetagselected = p_new(Bool **, screen_count);
|
2007-10-31 11:41:50 +01:00
|
|
|
clients = *awesomeconf_first->clients;
|
2007-10-31 11:37:38 +01:00
|
|
|
for (screen = 0; screen < screen_count; screen ++)
|
|
|
|
{
|
2007-10-31 11:41:50 +01:00
|
|
|
savetagnames[screen] = p_new(char *, awesomeconf_first[screen].ntags);
|
2007-10-31 11:43:17 +01:00
|
|
|
savetagclientsel[screen] = p_new(Client *, awesomeconf_first[screen].ntags);
|
2007-11-08 11:23:04 +01:00
|
|
|
savetagselected[screen] = p_new(Bool *, awesomeconf_first[screen].ntags);
|
2007-10-31 11:37:38 +01:00
|
|
|
for (tag = 0; tag < awesomeconf_first[screen].ntags; tag++)
|
|
|
|
{
|
2007-10-31 11:47:22 +01:00
|
|
|
savetagnames[screen][tag] = a_strdup(awesomeconf_first[screen].tags[tag].name);
|
2007-10-31 11:43:17 +01:00
|
|
|
savetagclientsel[screen][tag] = awesomeconf_first[screen].tags[tag].client_sel;
|
2007-11-08 11:23:04 +01:00
|
|
|
savetagselected[screen][tag] = p_new(Bool, 2);
|
|
|
|
savetagselected[screen][tag][0] = awesomeconf_first[screen].tags[tag].selected;
|
|
|
|
savetagselected[screen][tag][1] = awesomeconf_first[screen].tags[tag].was_selected;
|
2007-10-31 11:37:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
old_ntags = p_new(int, screen_count);
|
|
|
|
for (screen = 0; screen < screen_count; screen ++)
|
|
|
|
old_ntags[screen] = awesomeconf_first[screen].ntags;
|
|
|
|
|
|
|
|
mapping = p_new(int*, screen_count);
|
|
|
|
for(screen = 0; screen < screen_count; screen++)
|
|
|
|
{
|
2007-10-31 11:41:50 +01:00
|
|
|
/* Cleanup screens and reload their config. */
|
2007-10-31 11:37:38 +01:00
|
|
|
cleanup_screen(&awesomeconf_first[screen]);
|
2007-11-08 11:22:25 +01:00
|
|
|
setup_screen(&awesomeconf_first[screen], configpath);
|
2007-10-31 11:37:38 +01:00
|
|
|
|
2007-10-31 11:41:50 +01:00
|
|
|
/* Compute a mapping of tags between the old and new config, based on
|
|
|
|
* tag names. */
|
2007-10-31 11:37:38 +01:00
|
|
|
mapping[screen] = p_new(int, awesomeconf_first[screen].ntags);
|
|
|
|
for (i = 0; i < awesomeconf_first[screen].ntags; i ++)
|
|
|
|
{
|
|
|
|
mapping[screen][i] = -1;
|
|
|
|
for (j = 0; j < old_ntags[screen]; j ++)
|
2007-10-31 11:47:22 +01:00
|
|
|
if (!a_strcmp(savetagnames[screen][j], awesomeconf_first[screen].tags[i].name))
|
2007-10-31 11:37:38 +01:00
|
|
|
{
|
|
|
|
mapping[screen][i] = j;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-31 11:41:50 +01:00
|
|
|
/* Reinitialize the tags' client lists and selected client. */
|
|
|
|
*awesomeconf_first[screen].clients = clients;
|
2007-10-31 11:37:38 +01:00
|
|
|
for (tag = 0; tag < awesomeconf_first[screen].ntags; tag++)
|
|
|
|
if (mapping[screen][tag] >= 0)
|
2007-11-08 11:23:04 +01:00
|
|
|
{
|
2007-10-31 11:43:17 +01:00
|
|
|
awesomeconf_first[screen].tags[tag].client_sel = savetagclientsel[screen][mapping[screen][tag]];
|
2007-11-08 11:23:04 +01:00
|
|
|
awesomeconf_first[screen].tags[tag].selected = savetagselected[screen][mapping[screen][tag]][0];
|
|
|
|
awesomeconf_first[screen].tags[tag].was_selected = savetagselected[screen][mapping[screen][tag]][1];
|
|
|
|
}
|
2007-10-31 11:37:38 +01:00
|
|
|
drawstatusbar(&awesomeconf_first[screen]);
|
|
|
|
}
|
|
|
|
|
2007-10-31 11:41:50 +01:00
|
|
|
/* Reinitialize the 'tags' array of each client.
|
|
|
|
* Clients are assigned to the tags of the same name as in the previous
|
|
|
|
* awesomerc, or to tag #1 otherwise. */
|
2007-10-31 11:37:38 +01:00
|
|
|
for (c = *awesomeconf_first->clients; c; c = c->next)
|
|
|
|
{
|
|
|
|
old_c_ntags = old_ntags[c->screen];
|
|
|
|
new_c_ntags = awesomeconf_first[c->screen].ntags;
|
|
|
|
|
|
|
|
old_c_tags = c->tags;
|
|
|
|
c->tags = p_new(Bool, new_c_ntags);
|
|
|
|
for (i = 0; i < new_c_ntags; i ++)
|
|
|
|
if (mapping[c->screen][i] >= 0)
|
|
|
|
c->tags[i] = old_c_tags[mapping[c->screen][i]];
|
|
|
|
p_delete(&old_c_tags);
|
|
|
|
|
|
|
|
for (i = 0; i < new_c_ntags && c->tags[i] == 0; i++) {}
|
|
|
|
if (i == new_c_ntags)
|
|
|
|
c->tags[0] = 1;
|
|
|
|
|
|
|
|
saveprops(c, awesomeconf_first[c->screen].ntags);
|
|
|
|
}
|
|
|
|
|
2007-10-31 11:41:50 +01:00
|
|
|
/* Cleanup after ourselves */
|
2007-10-31 11:37:38 +01:00
|
|
|
for(screen = 0; screen < screen_count; screen++)
|
|
|
|
{
|
|
|
|
for(i = 0; i < old_ntags[screen]; i++)
|
2007-11-08 11:23:04 +01:00
|
|
|
{
|
2007-10-31 11:37:38 +01:00
|
|
|
p_delete(&savetagnames[screen][i]);
|
2007-11-08 11:23:04 +01:00
|
|
|
p_delete(&savetagselected[screen][i]);
|
|
|
|
}
|
|
|
|
p_delete(&savetagselected[screen]);
|
2007-10-31 11:37:38 +01:00
|
|
|
p_delete(&savetagnames[screen]);
|
|
|
|
p_delete(&mapping[screen]);
|
2007-10-31 11:48:37 +01:00
|
|
|
p_delete(&savetagclientsel[screen]);
|
2007-10-31 11:37:38 +01:00
|
|
|
}
|
|
|
|
p_delete(&mapping);
|
2007-11-08 11:23:04 +01:00
|
|
|
p_delete(&savetagselected);
|
2007-10-31 11:37:38 +01:00
|
|
|
p_delete(&savetagnames);
|
|
|
|
p_delete(&old_ntags);
|
2007-10-31 11:48:37 +01:00
|
|
|
p_delete(&savetagclientsel);
|
2007-11-08 11:22:25 +01:00
|
|
|
p_delete(&configpath);
|
2007-10-31 11:37:38 +01:00
|
|
|
for (screen = 0; screen < screen_count; screen ++)
|
|
|
|
arrange(&awesomeconf_first[screen]);
|
|
|
|
}
|
|
|
|
|
2007-10-15 13:56:24 +02:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|