add support for keycode instead of only string
This commit is contained in:
parent
bd8ede8d74
commit
db3931c549
|
@ -312,6 +312,7 @@ Note: when there is no whitespace, quotes are optional.
|
||||||
<image> -> "/home/awesome/pics/icon.png" (path to image)
|
<image> -> "/home/awesome/pics/icon.png" (path to image)
|
||||||
<integer> -> 1, 10, -3 (positive numbers are required mostly)
|
<integer> -> 1, 10, -3 (positive numbers are required mostly)
|
||||||
<key> -> a, 1, F10 (see /usr/include/X11/keysymdef.h w/o XK_ or 'xev')
|
<key> -> a, 1, F10 (see /usr/include/X11/keysymdef.h w/o XK_ or 'xev')
|
||||||
|
or a keycode beginning with #
|
||||||
<mod> -> "Mod1", "Mod4", "Control" (modifiers)
|
<mod> -> "Mod1", "Mod4", "Control" (modifiers)
|
||||||
<regex> -> regular expression
|
<regex> -> regular expression
|
||||||
<string> -> "foo bar"
|
<string> -> "foo bar"
|
||||||
|
|
17
config.c
17
config.c
|
@ -168,6 +168,19 @@ set_key_info(Key *key, cfg_t *cfg)
|
||||||
warn("unknown command %s\n", cfg_getstr(cfg, "command"));
|
warn("unknown command %s\n", cfg_getstr(cfg, "command"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static KeySym
|
||||||
|
key_to_keysym(char *str)
|
||||||
|
{
|
||||||
|
KeyCode kc;
|
||||||
|
int ikc;
|
||||||
|
|
||||||
|
if(a_strncmp(str, "#", 1))
|
||||||
|
return XStringToKeysym(str);
|
||||||
|
|
||||||
|
ikc = atoi(str + 1);
|
||||||
|
memcpy(&kc, &ikc, sizeof(KeyCode));
|
||||||
|
return XKeycodeToKeysym(globalconf.display, kc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static Key *
|
static Key *
|
||||||
section_keys(cfg_t *cfg_keys)
|
section_keys(cfg_t *cfg_keys)
|
||||||
|
@ -181,7 +194,7 @@ section_keys(cfg_t *cfg_keys)
|
||||||
key = p_new(Key, 1);
|
key = p_new(Key, 1);
|
||||||
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
||||||
set_key_info(key, cfgkeytmp);
|
set_key_info(key, cfgkeytmp);
|
||||||
key->keysym = XStringToKeysym(cfg_getstr(cfgkeytmp, "key"));
|
key->keysym = key_to_keysym(cfg_getstr(cfgkeytmp, "key"));
|
||||||
key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
|
key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
|
||||||
key_list_push(&head, key);
|
key_list_push(&head, key);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +213,7 @@ section_keys(cfg_t *cfg_keys)
|
||||||
{
|
{
|
||||||
key = p_new(Key, 1);
|
key = p_new(Key, 1);
|
||||||
set_key_info(key, cfgkeytmp);
|
set_key_info(key, cfgkeytmp);
|
||||||
key->keysym = XStringToKeysym(cfg_getnstr(cfgkeytmp, "keylist", j));
|
key->keysym = key_to_keysym(cfg_getnstr(cfgkeytmp, "keylist", j));
|
||||||
key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
|
key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
|
||||||
key_list_push(&head, key);
|
key_list_push(&head, key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue