Skip to content

Commit

Permalink
#93 implemented more efficient way of checking config file using inotify
Browse files Browse the repository at this point in the history
  • Loading branch information
ldrahnik committed Feb 17, 2023
1 parent b8a6682 commit d234588
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions asus_touchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@
CONFIG_PRESS_KEY_WHEN_IS_DONE_UNTOUCH_DEFAULT = 1

config_file_path = config_file_dir + CONFIG_FILE_NAME
inotify_adapters = adapters.Inotify()
inotify_adapters.add_watch(config_file_path)

config = configparser.ConfigParser()
config_lock = threading.Lock()

Expand Down Expand Up @@ -707,6 +704,10 @@ def load_all_config_values():

config = configparser.ConfigParser()
load_all_config_values()
config_save()

inotify_adapters = adapters.Inotify()
inotify_adapters.add_watch(config_file_path)

def set_tracking_id(value):
try:
Expand Down Expand Up @@ -1419,12 +1420,15 @@ def check_numpad_automatical_disable_due_inactivity():
def check_config_values_changes():
global inotify_adapters

for event in inotify_adapters.event_gen(yield_nones=False):
try:
for event in inotify_adapters.event_gen(yield_nones=False):

(_, type_names, path, filename) = event
(_, type_names, path, filename) = event

if "IN_CLOSE_WRITE" in type_names:
load_all_config_values()
if "IN_CLOSE_WRITE" in type_names:
load_all_config_values()
except:
pass


threads = []
Expand Down

0 comments on commit d234588

Please sign in to comment.