diff options
author | koekeishiya <aasvi93@hotmail.com> | 2019-02-23 14:49:56 +0100 |
---|---|---|
committer | koekeishiya <aasvi93@hotmail.com> | 2019-02-23 14:49:56 +0100 |
commit | 0e703c3f275f6d4477f452acfb9cf9c73b9d9f1e (patch) | |
tree | 6d46a0835b6614548ac9292067e8b3b4590e134f /src/skhd.c | |
parent | eeab7a37a2e017ea36d2385fd6b03b9572f181aa (diff) | |
download | skhd-0e703c3f275f6d4477f452acfb9cf9c73b9d9f1e.tar.gz skhd-0e703c3f275f6d4477f452acfb9cf9c73b9d9f1e.zip |
#59 reload config when input source changes
Diffstat (limited to '')
-rw-r--r-- | src/skhd.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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); |