[config] Use a string array as args for uicb

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-04 12:47:16 +02:00
parent 4c89bc0d0c
commit c3e063d55e
3 changed files with 120 additions and 466 deletions

View File

@ -50,104 +50,31 @@ screen 0
taglist mytaglist taglist mytaglist
{ {
mouse mouse { button = "1" command = "tag_view" }
{ mouse { button = "1" modkey = {"Mod4"} command = "client_tag" }
button = "1" mouse { button = "3" command = "tag_toggleview" }
command = "tag_view" mouse { button = "3" modkey = {"Mod4"} command = "client_toggletag" }
} mouse { button = "4" command = "tag_viewnext" }
mouse mouse { button = "5" command = "tag_viewprev" }
{
button = "1"
modkey = {"Mod4"}
command = "client_tag"
}
mouse
{
button = "3"
command = "tag_toggleview"
}
mouse
{
button = "3"
modkey = {"Mod4"}
command = "client_toggletag"
}
mouse
{
button = "4"
command = "tag_viewnext"
}
mouse
{
button = "5"
command = "tag_viewprev"
}
} }
layoutinfo mylayoutinfo layoutinfo mylayoutinfo
{ {
mouse mouse { button = "1" command = "tag_setlayout" args = {"+1"} }
{ mouse { button = "4" command = "tag_setlayout" args = {"+1"} }
button = "1" mouse { button = "3" command = "tag_setlayout" args = {"-1"} }
command = "tag_setlayout" mouse { button = "5" command = "tag_setlayout" args = {"-1"} }
arg = "+1"
}
mouse
{
button = "4"
command = "tag_setlayout"
arg = "+1"
}
mouse
{
button = "3"
command = "tag_setlayout"
arg = "-1"
}
mouse
{
button = "5"
command = "tag_setlayout"
arg = "-1"
}
} }
tasklist mytasklist tasklist mytasklist
{ {
mouse mouse { button = "4" command = "client_focus" args = {"+1"} }
{ mouse { button = "5" command = "client_focus" args = {"-1"} }
button = "4" mouse { modkey = {"Mod4"} button = "4" command = "client_swap" args = {"+1"} }
command = "client_focus" mouse { modkey = {"Mod4"} button = "5" command = "client_swap" args = {"-1"} }
arg = "+1"
}
mouse
{
button = "5"
command = "client_focus"
arg = "-1"
}
mouse
{
modkey = {"Mod4"}
button = "4"
command = "client_swap"
arg = "+1"
}
mouse
{
modkey = {"Mod4"}
button = "5"
command = "client_swap"
arg = "-1"
}
} }
iconbox logo iconbox logo
{ {
image = "@iconsdir@/awesome16.png" image = "@iconsdir@/awesome16.png"
mouse mouse { button = "1" command = "spawn" args = {"exec xterm -e man awesome"} }
{
button = "1"
command = "spawn"
arg = "exec xterm -e man awesome"
}
} }
} }
} }
@ -162,314 +89,94 @@ rules
mouse mouse
{ {
root root { button = "3" command = "spawn" args = {"exec xterm"} }
{ root { button = "4" command = "tag_viewnext" }
button = "3" root { button = "5" command = "tag_viewprev" }
command = "spawn" client { modkey = {"Mod4"} button = "1" command = "client_movemouse" }
arg = "exec xterm" client { modkey = {"Mod4"} button = "2" command = "client_swap" args = {"0"} }
} client { modkey = {"Mod4"} button = "3" command = "client_resizemouse" }
root titlebar { button = "1" command = "client_movemouse" }
{ titlebar { button = "3" command = "client_resizemouse" }
button = "4"
command = "tag_viewnext"
}
root
{
button = "5"
command = "tag_viewprev"
}
client
{
modkey = {"Mod4"}
button = "1"
command = "client_movemouse"
}
client
{
modkey = {"Mod4"}
button = "2"
command = "client_swap"
arg = "0"
}
client
{
modkey = {"Mod4"}
button = "3"
command = "client_resizemouse"
}
titlebar
{
button = "1"
command = "client_movemouse"
}
titlebar
{
button = "3"
command = "client_resizemouse"
}
} }
keys keys
{ {
key key { modkey = {"Mod4"} key = "F1" command = "spawn" args = {"for i in /usr/share/man/man?;do ls $i; done | cut -d. -f1 | awesome-menu -e 'xterm -e man ' 'See manual page for:'"} }
{ key { modkey = {"Mod4"} key = "F2" command = "spawn" args = {"find /usr/bin -type f -executable ! -empty | awesome-menu -e 'exec ' Execute:"} }
modkey = {"Mod4"} key { modkey = {"Mod4"} key = "F3" command = "spawn" args = {"cut -d' ' -f1 ~/.ssh/known_hosts | cut -d, -f1 | awesome-menu -e 'xterm -e ssh ' 'ssh to:'"} }
key = "F1" key { modkey = {"Mod4"} key = "Return" command = "spawn" args = {"exec xterm"} }
command = "spawn" key { modkey = {"Mod4"} key = "space" command = "tag_setlayout" args = {"+1"} }
arg = "for i in /usr/share/man/man?;do ls $i; done | cut -d. -f1 | awesome-menu -e 'xterm -e man ' 'See manual page for:'" key { modkey = {"Mod4", "Shift"} key = "space" command = "tag_setlayout" args = {"-1"} }
} key { modkey = {"Mod4"} key = "b" command = "statusbar_toggle" }
key key { modkey = {"Mod4"} key = "j" command = "client_focus" args = {"+1"} }
{ key { modkey = {"Mod4"} key = "k" command = "client_focus" args = {"-1"} }
modkey = {"Mod4"} key { modkey = {"Mod4"} key = "Tab" command = "focus_history" args = {"-1"} }
key = "F2" key { modkey = {"Mod4", "Shift"} key = "j" command = "client_swap" args = {"+1"} }
command = "spawn" key { modkey = {"Mod4", "Shift"} key = "k" command = "client_swap" args = {"-1"} }
arg = "find /usr/bin -type f -executable ! -empty | awesome-menu -e 'exec ' Execute:" key { modkey = {"Mod4", "Control"} key = "j" command = "screen_focus" args = {"+1"} }
} key { modkey = {"Mod4", "Control"} key = "k" command = "screen_focus" args = {"-1"} }
key key { modkey = {"Mod4"} key = "h" command = "tag_setmwfact" args = {"-0.05"} }
{ key { modkey = {"Mod4"} key = "l" command = "tag_setmwfact" args = {"+0.05"} }
modkey = {"Mod4"} key { modkey = {"Mod4", "Shift"} key = "h" command = "tag_setnmaster" args = {"+1"} }
key = "F3" key { modkey = {"Mod4", "Shift"} key = "l" command = "tag_setnmaster" args = {"-1"} }
command = "spawn" key { modkey = {"Mod4", "Control"} key = "h" command = "tag_setncol" args = {"+1"} }
arg = "cut -d' ' -f1 ~/.ssh/known_hosts | cut -d, -f1 | awesome-menu -e 'xterm -e ssh ' 'ssh to:'" key { modkey = {"Mod4", "Control"} key = "l" command = "tag_setncol" args = {"-1"} }
} key { modkey = {"Mod4"} key = "Escape" command = "tag_prev_selected" }
key key { modkey = {"Mod4"} key = "Left" command = "tag_viewprev" }
{ key { modkey = {"Mod4"} key = "Right" command = "tag_viewnext" }
modkey = {"Mod4"} key { modkey = {"Mod4"} key = "m" command = "client_togglemax" }
key = "Return" key { modkey = {"Mod4", "Control"} key = "Return" command = "client_swap" args = {"0"} }
command = "spawn" key { modkey = {"Mod4", "Control"} key = "space" command = "client_setfloating" }
arg = "exec xterm" key { modkey = {"Mod4"} key = "s" command = "client_togglescratch" }
} key { modkey = {"Mod4", "Control"} key = "s" command = "client_setscratch" }
key key { modkey = {"Mod4", "Shift"} key = "c" command = "client_kill" }
{ key { modkey = {"Mod4", "Shift"} key = "q" command = "quit" }
modkey = {"Mod4"} key { modkey = {"Mod4", "Control"} key = "r" command = "restart" }
key = "space"
command = "tag_setlayout"
arg = "+1"
}
key
{
modkey = {"Mod4", "Shift"}
key = "space"
command = "tag_setlayout"
arg = "-1"
}
key
{
modkey = {"Mod4"}
key = "b"
command = "statusbar_toggle"
}
key
{
modkey = {"Mod4"}
key = "j"
command = "client_focus"
arg = "+1"
}
key
{
modkey = {"Mod4"}
key = "k"
command = "client_focus"
arg = "-1"
}
key
{
modkey = {"Mod4"}
key = "Tab"
command = "focus_history"
arg = "-1"
}
key
{
modkey = {"Mod4", "Shift"}
key = "j"
command = "client_swap"
arg = "+1"
}
key
{
modkey = {"Mod4", "Shift"}
key = "k"
command = "client_swap"
arg = "-1"
}
key
{
modkey = {"Mod4", "Control"}
key = "j"
command = "screen_focus"
arg = "+1"
}
key
{
modkey = {"Mod4", "Control"}
key = "k"
command = "screen_focus"
arg = "-1"
}
key
{
modkey = {"Mod4"}
key = "h"
command = "tag_setmwfact"
arg = "-0.05"
}
key
{
modkey = {"Mod4"}
key = "l"
command = "tag_setmwfact"
arg = "+0.05"
}
key
{
modkey = {"Mod4", "Shift"}
key = "h"
command = "tag_setnmaster"
arg = "+1"
}
key
{
modkey = {"Mod4", "Shift"}
key = "l"
command = "tag_setnmaster"
arg = "-1"
}
key
{
modkey = {"Mod4", "Control"}
key = "h"
command = "tag_setncol"
arg = "+1"
}
key
{
modkey = {"Mod4", "Control"}
key = "l"
command = "tag_setncol"
arg = "-1"
}
key
{
modkey = {"Mod4"}
key = "Escape"
command = "tag_prev_selected"
}
key
{
modkey = {"Mod4"}
key = "Left"
command = "tag_viewprev"
}
key
{
modkey = {"Mod4"}
key = "Right"
command = "tag_viewnext"
}
key
{
modkey = {"Mod4"}
key = "m"
command = "client_togglemax"
}
key
{
modkey = {"Mod4", "Control"}
key = "Return"
command = "client_swap"
arg = "0"
}
key
{
modkey = {"Mod4", "Control"}
key = "space"
command = "client_setfloating"
}
key
{
modkey = {"Mod4"}
key = "s"
command = "client_togglescratch"
}
key
{
modkey = {"Mod4", "Control"}
key = "s"
command = "client_setscratch"
}
key
{
modkey = {"Mod4", "Shift"}
key = "c"
command = "client_kill"
}
key
{
modkey = {"Mod4", "Shift"}
key = "q"
command = "quit"
}
key
{
modkey = {"Mod4", "Control"}
key = "r"
command = "restart"
}
key
{
modkey = {"Mod4"}
key = "0"
command = "tag_view"
}
keylist
{
modkey = {"Mod4"}
command = "tag_view"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
key
{
modkey = {"Mod4", "Control"}
key = "0"
command = "tag_toggleview"
}
keylist
{
modkey = {"Mod4", "Control"}
command = "tag_toggleview"
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
key key { modkey = {"Mod4"} key = "0" command = "tag_view" }
{ key { modkey = {"Mod4"} key = "0" command = "tag_view" }
modkey = {"Mod4", "Shift"} key { modkey = {"Mod4"} key = "1" command = "tag_view" args = {"1"} }
key = "0" key { modkey = {"Mod4"} key = "2" command = "tag_view" args = {"2"} }
command = "client_tag" key { modkey = {"Mod4"} key = "3" command = "tag_view" args = {"3"} }
} key { modkey = {"Mod4"} key = "4" command = "tag_view" args = {"4"} }
keylist key { modkey = {"Mod4"} key = "5" command = "tag_view" args = {"5"} }
{ key { modkey = {"Mod4"} key = "6" command = "tag_view" args = {"6"} }
modkey = {"Mod4", "Shift"} key { modkey = {"Mod4"} key = "7" command = "tag_view" args = {"7"} }
command = "client_tag" key { modkey = {"Mod4"} key = "8" command = "tag_view" args = {"8"} }
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } key { modkey = {"Mod4"} key = "9" command = "tag_view" args = {"9"} }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
}
key key { modkey = {"Mod4"} key = "0" command = "tag_toggleview" }
{ key { modkey = {"Mod4", "Control"} key = "0" command = "tag_toggleview" }
modkey = {"Mod4", "Shift", "Control"} key { modkey = {"Mod4", "Control"} key = "1" command = "tag_toggleview" args = {"1"} }
key = "0" key { modkey = {"Mod4", "Control"} key = "2" command = "tag_toggleview" args = {"2"} }
command = "client_toggletag" key { modkey = {"Mod4", "Control"} key = "3" command = "tag_toggleview" args = {"3"} }
} key { modkey = {"Mod4", "Control"} key = "4" command = "tag_toggleview" args = {"4"} }
keylist key { modkey = {"Mod4", "Control"} key = "5" command = "tag_toggleview" args = {"5"} }
{ key { modkey = {"Mod4", "Control"} key = "6" command = "tag_toggleview" args = {"6"} }
modkey = {"Mod4", "Shift", "Control"} key { modkey = {"Mod4", "Control"} key = "7" command = "tag_toggleview" args = {"7"} }
command = "client_toggletag" key { modkey = {"Mod4", "Control"} key = "8" command = "tag_toggleview" args = {"8"} }
keylist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } key { modkey = {"Mod4", "Control"} key = "9" command = "tag_toggleview" args = {"9"} }
arglist = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
} key { modkey = {"Mod4", "Shift"} key = "0" command = "client_tag" }
key { modkey = {"Mod4", "Shift"} key = "1" command = "client_tag" args = {"1"} }
key { modkey = {"Mod4", "Shift"} key = "2" command = "client_tag" args = {"2"} }
key { modkey = {"Mod4", "Shift"} key = "3" command = "client_tag" args = {"3"} }
key { modkey = {"Mod4", "Shift"} key = "4" command = "client_tag" args = {"4"} }
key { modkey = {"Mod4", "Shift"} key = "5" command = "client_tag" args = {"5"} }
key { modkey = {"Mod4", "Shift"} key = "6" command = "client_tag" args = {"6"} }
key { modkey = {"Mod4", "Shift"} key = "7" command = "client_tag" args = {"7"} }
key { modkey = {"Mod4", "Shift"} key = "8" command = "client_tag" args = {"8"} }
key { modkey = {"Mod4", "Shift"} key = "9" command = "client_tag" args = {"9"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "0" command = "client_toggletag" }
key { modkey = {"Mod4", "Shift", "Control"} key = "1" command = "client_toggletag" args = {"1"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "2" command = "client_toggletag" args = {"2"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "3" command = "client_toggletag" args = {"3"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "4" command = "client_toggletag" args = {"4"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "5" command = "client_toggletag" args = {"5"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "6" command = "client_toggletag" args = {"6"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "7" command = "client_toggletag" args = {"7"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "8" command = "client_toggletag" args = {"8"} }
key { modkey = {"Mod4", "Shift", "Control"} key = "9" command = "client_toggletag" args = {"9"} }
} }
# vim: filetype=conf # vim: filetype=conf

View File

@ -248,8 +248,8 @@ cfg_opt_t mouse_generic_opts[] =
CFG_STR((char *) "button", (char *) "XCB_NONE", CFGF_NONE), CFG_STR((char *) "button", (char *) "XCB_NONE", CFGF_NONE),
/** Uicb command to run. */ /** Uicb command to run. */
CFG_STR((char *) "command", NULL, CFGF_NONE), CFG_STR((char *) "command", NULL, CFGF_NONE),
/** Argument to use for command. */ /** Arguments to use for command. */
CFG_STR((char *) "arg", NULL, CFGF_NONE), CFG_STR_LIST((char *) "args", NULL, CFGF_NONE),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
/** This section defines common widgets options. */ /** This section defines common widgets options. */
@ -568,20 +568,7 @@ cfg_opt_t key_opts[] =
/** Uicb command to run. */ /** Uicb command to run. */
CFG_STR((char *) "command", (char *) "", CFGF_NONE), CFG_STR((char *) "command", (char *) "", CFGF_NONE),
/** Argument to use for command. */ /** Argument to use for command. */
CFG_STR((char *) "arg", NULL, CFGF_NONE), CFG_STR_LIST((char *) "args", NULL, CFGF_NONE),
CFG_AWESOME_END()
};
/** This section defines keylist options. */
cfg_opt_t keylist_opts[] =
{
/** Modifier keys. */
CFG_STR_LIST((char *) "modkey", (char *) "", CFGF_NONE),
/** List of keys, order matters. */
CFG_STR_LIST((char *) "keylist", (char *) NULL, CFGF_NONE),
/** Uicb command to run. */
CFG_STR((char *) "command", (char *) "", CFGF_NONE),
/** List of arguments for command, order matters. */
CFG_STR_LIST((char *) "arglist", NULL, CFGF_NONE),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
/** This section defines keys options. */ /** This section defines keys options. */
@ -589,8 +576,6 @@ cfg_opt_t keys_opts[] =
{ {
/** A key binding. */ /** A key binding. */
CFG_SEC((char *) "key", key_opts, CFGF_MULTI), CFG_SEC((char *) "key", key_opts, CFGF_MULTI),
/** A list of key bindings. */
CFG_SEC((char *) "keylist", keylist_opts, CFGF_MULTI),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
/** This section defines mouse options. */ /** This section defines mouse options. */

View File

@ -144,7 +144,7 @@ parse_mouse_bindings(cfg_t * cfg, const char *secname, bool handle_arg)
if(!b->func) if(!b->func)
warn("unknown command %s\n", cfg_getstr(cfgsectmp, "command")); warn("unknown command %s\n", cfg_getstr(cfgsectmp, "command"));
if(handle_arg) if(handle_arg)
b->arg = a_strdup(cfg_getstr(cfgsectmp, "arg")); b->arg = a_strdup(cfg_getnstr(cfgsectmp, "args", 0));
else else
b->arg = NULL; b->arg = NULL;
@ -154,19 +154,6 @@ parse_mouse_bindings(cfg_t * cfg, const char *secname, bool handle_arg)
return head; return head;
} }
static void
set_key_info(keybinding_t *key, cfg_t *cfg)
{
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)
warn("unknown command %s\n", cfg_getstr(cfg, "command"));
}
static void static void
config_key_store(keybinding_t *key, char *str) config_key_store(keybinding_t *key, char *str)
{ {
@ -185,47 +172,6 @@ config_key_store(keybinding_t *key, char *str)
} }
} }
static keybinding_t *
section_keys(cfg_t *cfg_keys)
{
keybinding_t *key = NULL, *head = NULL;
int i, j, numkeys;
cfg_t *cfgkeytmp;
for(i = cfg_size(cfg_keys, "key") - 1; i >= 0; i--)
{
key = p_new(keybinding_t, 1);
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
set_key_info(key, cfgkeytmp);
config_key_store(key, cfg_getstr(cfgkeytmp, "key"));
key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
keybinding_list_push(&head, key);
}
for(i = cfg_size(cfg_keys, "keylist") - 1; i >= 0; i--)
{
cfgkeytmp = cfg_getnsec(cfg_keys, "keylist", i);
numkeys = cfg_size(cfgkeytmp, "keylist");
if(numkeys != (int) cfg_size(cfgkeytmp, "arglist"))
{
warn("number of keys != number of args in keylist");
continue;
}
for(j = 0; j < numkeys; j++)
{
key = p_new(keybinding_t, 1);
set_key_info(key, cfgkeytmp);
config_key_store(key, cfg_getnstr(cfgkeytmp, "keylist", j));
key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
keybinding_list_push(&head, key);
}
}
return head;
}
static int static int
cmp_widget_cfg(const void *a, const void *b) cmp_widget_cfg(const void *a, const void *b)
{ {
@ -471,8 +417,10 @@ config_parse(const char *confpatharg)
{ {
cfg_t *cfg, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp; cfg_t *cfg, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp;
int ret, screen, i; int ret, screen, i;
unsigned int j;
char *confpath; char *confpath;
rule_t *rule = NULL; rule_t *rule = NULL;
keybinding_t *key;
FILE *defconfig = NULL; FILE *defconfig = NULL;
if(confpatharg) if(confpatharg)
@ -537,6 +485,22 @@ config_parse(const char *confpatharg)
rule_list_push(&globalconf.rules, rule); rule_list_push(&globalconf.rules, rule);
} }
/* Key bindings */
keybinding_list_init(&globalconf.keys);
for(i = cfg_size(cfg_keys, "key") - 1; i >= 0; i--)
{
key = p_new(keybinding_t, 1);
cfgsectmp = cfg_getnsec(cfg_keys, "key", i);
config_key_store(key, cfg_getstr(cfgsectmp, "key"));
for(j = 0; j < cfg_size(cfgsectmp, "modkey"); j++)
key->mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", j));
if(!(key->func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), UicbList)))
warn("unknown command %s\n", cfg_getstr(cfgsectmp, "command"));
key->arg = a_strdup(cfg_getnstr(cfgsectmp, "args", 0));
printf("key %s %s %d\n", cfg_getstr(cfgsectmp, "command"), key->arg, key->keysym);
keybinding_list_push(&globalconf.keys, key);
}
/* Mouse: root window click bindings */ /* Mouse: root window click bindings */
globalconf.buttons.root = parse_mouse_bindings(cfg_mouse, "root", true); globalconf.buttons.root = parse_mouse_bindings(cfg_mouse, "root", true);
@ -546,8 +510,6 @@ config_parse(const char *confpatharg)
/* Mouse: titlebar windows click bindings */ /* Mouse: titlebar windows click bindings */
globalconf.buttons.titlebar = parse_mouse_bindings(cfg_mouse, "titlebar", true); globalconf.buttons.titlebar = parse_mouse_bindings(cfg_mouse, "titlebar", true);
globalconf.keys = section_keys(cfg_keys);
if(defconfig) if(defconfig)
{ {
fwrite(AWESOME_DEFAULT_CONFIG, a_strlen(AWESOME_DEFAULT_CONFIG), 1, defconfig); fwrite(AWESOME_DEFAULT_CONFIG, a_strlen(AWESOME_DEFAULT_CONFIG), 1, defconfig);