live reload config file with SIGUSR1

xkbcommon
Alessandro Mauri 4 years ago
parent 8ad875b311
commit d6b8e129d7
  1. 5
      hkd.1
  2. 6
      hkd.c

@ -80,6 +80,11 @@ 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 lower case, as such hotkeys that require a capitalized letter need to include
RIGHTSHIFT or LEFTSHIFT in the keys section. RIGHTSHIFT or LEFTSHIFT in the keys section.
Keys are intended as a list of comma separated strings. Keys are intended as a list of comma separated strings.
.PP
hkd can live reload the configuration file by signaling it with
.I SIGUSR1
for example with the command "$ pkill -USR1 -x hkd", for easier use one could add
an hotkey to execute that command.
.SH EXAMPLES .SH EXAMPLES
This is a valid config file example This is a valid config file example

@ -298,6 +298,7 @@ int main (int argc, char *argv[])
memset(&action, 0, sizeof(action)); memset(&action, 0, sizeof(action));
action.sa_handler = int_handler; action.sa_handler = int_handler;
sigaction(SIGINT, &action, NULL); sigaction(SIGINT, &action, NULL);
sigaction(SIGUSR1, &action, NULL);
/* Parse config file */ /* Parse config file */
parse_config_file(); parse_config_file();
@ -479,6 +480,9 @@ void int_handler (int signum)
printf(yellow("Received interrupt signal, exiting gracefully...\n")); printf(yellow("Received interrupt signal, exiting gracefully...\n"));
dead = 1; dead = 1;
break; break;
case SIGUSR1:
parse_config_file();
break;
} }
} }
@ -725,6 +729,8 @@ void parse_config_file (void)
if (!fd) if (!fd)
die("Could not open any config files, check the log for more details"); die("Could not open any config files, check the log for more details");
} }
hotkey_list_destroy(hotkey_list);
while (exit_state >= 0) { while (exit_state >= 0) {
int tmp = 0; int tmp = 0;
memset(block, 0, BLOCK_SIZE + 1); memset(block, 0, BLOCK_SIZE + 1);

Loading…
Cancel
Save