@@ -29,8 +29,9 @@ import sys
2929from enum import Enum
3030from typing import Union , Optional
3131
32- from inputremapper .configs .global_config import global_config
32+ from inputremapper .configs .global_config import GlobalConfig
3333from inputremapper .configs .migrations import Migrations
34+ from inputremapper .injection .global_uinputs import GlobalUInputs , UInput , FrontendUInput
3435from inputremapper .logging .logger import logger
3536
3637
@@ -66,6 +67,14 @@ class Options:
6667
6768
6869class InputRemapperControl :
70+ def __init__ (
71+ self ,
72+ global_config : GlobalConfig ,
73+ migrations : Migrations ,
74+ ):
75+ self .global_config = global_config
76+ self .migrations = migrations
77+
6978 def run (self , cmd ) -> None :
7079 """Run and log a command."""
7180 logger .info ("Running `%s`..." , cmd )
@@ -81,9 +90,9 @@ class InputRemapperControl:
8190 print (group .key )
8291
8392 def list_key_names (self ):
84- from inputremapper .configs .system_mapping import system_mapping
93+ from inputremapper .configs .keyboard_layout import keyboard_layout
8594
86- print ("\n " .join (system_mapping .list_names ()))
95+ print ("\n " .join (keyboard_layout .list_names ()))
8796
8897 def communicate (
8998 self ,
@@ -131,7 +140,7 @@ class InputRemapperControl:
131140 sys .exit (6 )
132141
133142 logger .info ('Using config from "%s" instead' , path )
134- global_config .load_config (path )
143+ self . global_config .load_config (path )
135144
136145 def ensure_migrated (self ) -> None :
137146 # import stuff late to make sure the correct log level is applied
@@ -144,9 +153,9 @@ class InputRemapperControl:
144153 # This will also refresh the config of the daemon if the user changed
145154 # it in the meantime.
146155 # config_dir is either the cli arg or the default path in home
147- config_dir = os .path .dirname (global_config .path )
156+ config_dir = os .path .dirname (self . global_config .path )
148157 self .daemon .set_config_dir (config_dir )
149- Migrations .migrate ()
158+ self . migrations .migrate ()
150159
151160 def _stop (self , device : str ) -> None :
152161 group = self ._require_group (device )
@@ -267,7 +276,14 @@ class InputRemapperControl:
267276
268277
269278def main (options : Options ) -> None :
270- input_remapper_control = InputRemapperControl ()
279+ global_config = GlobalConfig ()
280+ global_uinputs = GlobalUInputs (FrontendUInput )
281+ migrations = Migrations (global_uinputs )
282+ input_remapper_control = InputRemapperControl (
283+ global_config ,
284+ migrations ,
285+ )
286+
271287 if options .debug :
272288 logger .update_verbosity (True )
273289
0 commit comments