aboutsummaryrefslogtreecommitdiff
path: root/src/skhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/skhd.c')
-rw-r--r--src/skhd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/skhd.c b/src/skhd.c
index de73ccd..77168c8 100644
--- a/src/skhd.c
+++ b/src/skhd.c
@@ -87,11 +87,23 @@ parse_config_helper(char *absolutepath)
internal HOTLOADER_CALLBACK(config_handler)
{
BEGIN_TIMED_BLOCK("hotload_config");
+ debug("skhd: config-file has been modified.. reloading config\n");
free_mode_map(&mode_map);
parse_config_helper(absolutepath);
END_TIMED_BLOCK();
}
+internal CF_NOTIFICATION_CALLBACK(keymap_handler)
+{
+ BEGIN_TIMED_BLOCK("keymap_changed");
+ if (initialize_keycode_map()) {
+ debug("skhd: input source changed.. reloading config\n");
+ free_mode_map(&mode_map);
+ parse_config_helper(config_file);
+ }
+ END_TIMED_BLOCK();
+}
+
internal EVENT_TAP_CALLBACK(key_handler)
{
switch (type) {
@@ -232,6 +244,13 @@ int main(int argc, char **argv)
use_default_config_path();
}
+ CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
+ NULL,
+ &keymap_handler,
+ kTISNotifySelectedKeyboardInputSourceChanged,
+ NULL,
+ CFNotificationSuspensionBehaviorCoalesce);
+
signal(SIGCHLD, SIG_IGN);
init_shell();
table_init(&mode_map, 13, (table_hash_func) hash_mode, (table_compare_func) same_mode);