From 2564189a769a5bd3de63086bb62dc3532d1b07b9 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Sat, 6 Apr 2024 21:53:25 -0600 Subject: added menubutton bind for i3, refactoring --- src/load_config.py | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'src/load_config.py') diff --git a/src/load_config.py b/src/load_config.py index dbc0d81..e28e9c3 100644 --- a/src/load_config.py +++ b/src/load_config.py @@ -9,19 +9,21 @@ class systemConfig: file for instant rice. """ - i3_config = "" - i3_lock_image = "" - polybar_config = "" - wallpaper_directory = "" - rofi_config = "" - username = "" - rice_config = "" - #instant rice configuration settings - num_palettes = 15 - use_dmenu = False - generate_i3_lock = False - + def __init__(self): + self.i3_config = "" + self.i3_lock_image = "" + self.polybar_config = "" + self.wallpaper_directory = "" + self.rofi_config = "" + self.username = "" + self.rice_config = "" + #instant rice configuration settings + self.num_palettes = 15 + self.use_dmenu = False + self.generate_i3_lock = False + self.menu_keybind = "" + print('[bold green]Loading configuration files') #Grab username to find configuration files @@ -64,19 +66,29 @@ class systemConfig: for i, line in enumerate(data): if "use_dmenu" in line: match = line.split(' ') - self.use_dmenu = True if match[2] == 'True' else False + self.use_dmenu = True if match[2].lower() == 'true' else False + if "generate_i3_lock" in line: match = line.split(' ') - self.generate_i3_lock = True if match[2] == 'True' else False + self.generate_i3_lock = True if match[2].lower() == 'true' else False + if "wallpaper_directory" in line: match = line.strip().split(' ') if not match[2].endswith('/'): match[2] += '/' - self.wallpaper_directory = match[2] + if os.path.exists(match[2]): + self.wallpaper_directory = match[2] + else: + print(f'Invalid configuration parameter at line {i}:\n{line}Directory does not exist; Please fix error before rerunning.') + if "num_palettes" in line: match = line.strip().split(' ') if match[2].isdigit(): self.num_palettes = int(match[2]) else: - print(f'Invalid configuration parameter at line {i}:\n{line}.\nUsing default \ - configuration of 15 palettes.') + print(f'Invalid configuration parameter at line {i}:\n{line}Using default configuration of 15 palettes.') + + if "menu_keybind" in line: + match = line.strip().split(' ') + self.menu_keybind = match[2] + print(self.menu_keybind) -- cgit v1.2.3