From d3f5e888e311e9d119d6361eab4f2c62eeffaf28 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Mon, 28 Sep 2020 22:47:59 +0200 Subject: [PATCH] parse keys as case-insensitive --- hkd.1 | 6 ++---- hkd.c | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hkd.1 b/hkd.1 index 44bcc42..e95fb0a 100644 --- a/hkd.1 +++ b/hkd.1 @@ -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_", in this configuration file only the 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 diff --git a/hkd.c b/hkd.c index 4a88afc..7c5d54d 100644 --- a/hkd.c +++ b/hkd.c @@ -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;