From b8c16ed06d884545729f3ea4569926384810412e Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Fri, 5 Feb 2021 00:58:29 +0300 Subject: [PATCH] Reload config on SIGUSR1 --- huion_keys.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/huion_keys.py b/huion_keys.py index 9bf6e5c..b42254b 100755 --- a/huion_keys.py +++ b/huion_keys.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import os import time +import signal from _xdo_cffi import ffi, lib @@ -22,6 +23,7 @@ def main(): create_default_config(CONFIG_FILE_PATH) print("Created an example config file at " + CONFIG_FILE_PATH) return 1 + signal.signal(signal.SIGUSR1, handle_reload_signal) # Reload the config if recieved SIGUSR1 prev_button = None while True: hidraw_path = None @@ -102,6 +104,9 @@ def read_config(config_file): else: print("[WARN] unrecognized setting '%s'" % (setting,)) +def handle_reload_signal(signum, frame): + print("SIGUSR1 recieved - reloading config..") + read_config(CONFIG_FILE_PATH) def create_default_config(config_file): with open(config_file, 'w') as config: