2323from gi .repository import Gio , Gtk , Pango , Gdk , XApp
2424
2525CURRENT_PATH = os .path .dirname (os .path .abspath (__file__ ))
26- MODULE_PATH = os .path .join (CURRENT_PATH , "modules" )
27- MODULE_GLOB = os .path .join (MODULE_PATH , "cs_*.py" )
28- MODULES = [Path (file ).stem for file in glob .glob (MODULE_GLOB )]
26+ PYTHON_CS_MODULE_PATH = os .path .join (CURRENT_PATH , "modules" )
27+ PYTHON_CS_MODULE_GLOB = os .path .join (PYTHON_CS_MODULE_PATH , "cs_*.py" )
28+ PYTHON_CS_MODULES = [Path (file ).stem for file in glob .glob (PYTHON_CS_MODULE_GLOB )]
2929BIN_PATH = os .path .join (CURRENT_PATH , "bin" )
30- sys .path .append (MODULE_PATH )
30+ sys .path .append (PYTHON_CS_MODULE_PATH )
3131sys .path .append (BIN_PATH )
3232from bin import capi
3333from bin import proxygsettings
@@ -395,7 +395,8 @@ def init_settings_overview(self):
395395 self .window .show ()
396396
397397 def load_sidepage_as_standalone (self , args ) -> bool :
398- self .load_python_modules (only_module = args .module )
398+ if f"cs_{ args .module } " in PYTHON_CS_MODULES :
399+ self .load_python_modules (only_module = args .module )
399400
400401 if args .tab is not None :
401402 module_tabs = TABS .get (args .module , {"default" : 0 })
@@ -437,9 +438,9 @@ def load_ccc_modules(self):
437438 else :
438439 print ("warning: failed to process CCC module" , item [1 ])
439440
440- def load_standalone_modules (self , MODULES : list ) -> None :
441+ def load_standalone_modules (self , mods : list ) -> None :
441442 """Loads all standalone settings modules."""
442- for item in MODULES :
443+ for item in mods :
443444 samodule = SettingsWidgets .SAModule (item [0 ], item [1 ], item [2 ], item [3 ], item [4 ], self .content_box )
444445 if samodule .process ():
445446 self .sidePages .append (SidePageData (samodule .sidePage , samodule .name , samodule .category ))
@@ -459,7 +460,7 @@ def load_python_modules(self, only_module: str = None) -> bool:
459460 if only_module is not None :
460461 to_import = [f"cs_{ only_module } " ]
461462 else :
462- to_import = MODULES
463+ to_import = PYTHON_CS_MODULES
463464
464465 for module in map (__import__ , to_import ):
465466 try :
@@ -752,7 +753,7 @@ def _quit(self, *args):
752753if __name__ == "__main__" :
753754 formatted_mods = ""
754755 i = 0
755- for mod in MODULES :
756+ for mod in PYTHON_CS_MODULES :
756757 formatted_mods += mod .replace ("cs_" , "" ) + ", "
757758 i += 1
758759 if i == 8 :
@@ -784,9 +785,12 @@ def _quit(self, *args):
784785 parser .add_argument ('-p' , '--panel' , type = str , metavar = "PANEL_ID" , help = "If opening the panel or applets module, specify a starting panel by its id" )
785786 args = parser .parse_args ()
786787
787- if args .module is not None and f"cs_{ args .module } " not in MODULES :
788+ def find_module_name (name ):
789+ return f"cs_{ name } " in PYTHON_CS_MODULES or name in [item [1 ] for item in CONTROL_CENTER_MODULES ]
790+
791+ if args .module is not None and not find_module_name (args .module ):
788792 new_mod = CS_MODULE_ALIASES .get (args .module , None )
789- if new_mod is None :
793+ if not find_module_name ( new_mod ) :
790794 print (f"warning: settings module { args .module } not found. Ignoring any remaining arguments." )
791795 args .module = new_mod
792796
0 commit comments