From fba95abb417e0907c6148b61acae791ae01adb28 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Sat, 13 Apr 2024 13:44:44 -0600 Subject: more smarter and better --- src/get_args.py | 17 +++++++++++------ src/theme.py | 12 ------------ src/user_interface.py | 2 +- 3 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 src/theme.py (limited to 'src') diff --git a/src/get_args.py b/src/get_args.py index 9197995..5419fc4 100644 --- a/src/get_args.py +++ b/src/get_args.py @@ -17,19 +17,15 @@ def get_args(args, walls_dir, theme_dir) -> tuple: index = args.index('-p') isFile = os.path.isfile(args[index + 1]) if isFile == True: - print("reached") theme = manage_saves.load_theme(args[index + 1]) + img_path = grab_image(args) elif '-t' in args: theme = user_interface.themeSelector(theme_dir) img_path = theme['wallpaper'] elif '-r' in args: img_path = user_interface.pickRandomWallpaper(walls_dir) else: - img_path = f"{os.getcwd()}/{args[1]}" - if not os.path.exists(img_path) and\ - args[1] not in VALID_ARGS: - print(f'[bold red]ERROR: invalid image path {os.getcwd()}/{args[1]}') - exit(2) + img_path = grab_image(args) if '--initialize' in args: initialize = True @@ -38,6 +34,15 @@ def get_args(args, walls_dir, theme_dir) -> tuple: return img_path, initialize, reconfigure, theme +def grab_image(args): + img_path = f"{os.getcwd()}/{args[1]}" + if not os.path.exists(img_path): + print(f'[bold red]ERROR: invalid image path {os.getcwd()}/{args[1]}') + exit(2) + else: + return img_path + + def usage(args) -> None: print(f"""Instant Rice - An automatic theming utilitiy diff --git a/src/theme.py b/src/theme.py deleted file mode 100644 index 4bda7e1..0000000 --- a/src/theme.py +++ /dev/null @@ -1,12 +0,0 @@ - -class Theme: - def __init__(self, colors, comp_colors, wallpaper): - self.colors = colors - self.comp_colors = comp_colors - self.wallpaper = wallpaper - def toDict(self): - return { - "colors" : self.colors, - "comp_colors": self.comp_colors, - "wallpaper" : self.wallpaper - } diff --git a/src/user_interface.py b/src/user_interface.py index 1ac0636..d79dbb9 100644 --- a/src/user_interface.py +++ b/src/user_interface.py @@ -126,7 +126,7 @@ def themeSelector(theme_dir): comp_colors += f'[on {theme['comp_colors'][j]}] [/on {theme['comp_colors'][j]}]' print(f'{colors} Theme ({i}): {theme['name']}\n{comp_colors} Wallpaper: {theme['wallpaper']}') os.system(f'viu {theme['wallpaper']} -w 50') - print('[bold green]Select theme (IE, 4)') + print(f'[bold green]Select theme (0, {num_themes})') while True: -- cgit v1.2.3