parse keys as case-insensitive

This commit is contained in:
Alessandro Mauri 2020-09-28 22:47:59 +02:00
parent 79bbbcf8a9
commit d3f5e888e3
2 changed files with 6 additions and 4 deletions

6
hkd.1
View File

@ -76,10 +76,8 @@ include normal keys, multimedia keys and special keys, for the full list
of available keys either refer to the header file or this project's hkd.c
source file. Keys as specified by the kernel are named "KEY_<name>", in this
configuration file only the <name> is required.
Key names are always capitalized and do not differenciate between upper or
lower case, as such hotkeys that require a capitalized letter need to include
RIGHTSHIFT or LEFTSHIFT in the keys section.
Keys are intended as a list of comma separated strings.
Key names are case-insensitive and are parsed as a list of comma separated
strings, such as: 'leftmeta,UP', 'VOLUMEUP' or 'leftctrl,LEFTALT,cancel'.
.PP
hkd can live reload the configuration file by signaling it with
.I SIGUSR1

4
hkd.c
View File

@ -918,6 +918,10 @@ void parse_config_file (void)
unsigned short key_to_code (char *key)
{
for (char *tmp = key; *tmp; tmp++) {
if (islower(*tmp))
*tmp += 'A' - 'a';
}
for (int i = 0; i < array_size_const(key_conversion_table); i++) {
if (!strcmp(key_conversion_table[i].name, key))
return key_conversion_table[i].value;