From 7b11e0a301340b4aa4f96fedb7fd2b0ba05cc91f Mon Sep 17 00:00:00 2001 From: benex Date: Sat, 16 Nov 2024 21:32:37 +0300 Subject: [PATCH] feat: add rofi-theme-preview option --- fastanime/cli/__init__.py | 8 ++++++++ fastanime/cli/config.py | 10 +++++++++- fastanime/libs/rofi/__init__.py | 5 +++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/fastanime/cli/__init__.py b/fastanime/cli/__init__.py index 43bffde..b837f33 100644 --- a/fastanime/cli/__init__.py +++ b/fastanime/cli/__init__.py @@ -158,6 +158,9 @@ signal.signal(signal.SIGINT, handle_exit) @click.option("--sub", help="Set the translation type to sub", is_flag=True) @click.option("--rofi", help="Use rofi for the ui", is_flag=True) @click.option("--rofi-theme", help="Rofi theme to use", type=click.Path()) +@click.option( + "--rofi-theme-preview", help="Rofi theme to use for previews", type=click.Path() +) @click.option( "--rofi-theme-confirm", help="Rofi theme to use for the confirm prompt", @@ -210,6 +213,7 @@ def run_cli( sub, rofi, rofi_theme, + rofi_theme_preview, rofi_theme_confirm, rofi_theme_input, use_python_mpv, @@ -325,6 +329,10 @@ def run_cli( if rofi: from ..libs.rofi import Rofi + if rofi_theme_preview: + ctx.obj.rofi_theme_preview = rofi_theme_preview + Rofi.rofi_theme_preview = rofi_theme_preview + if rofi_theme: ctx.obj.rofi_theme = rofi_theme Rofi.rofi_theme = rofi_theme diff --git a/fastanime/cli/config.py b/fastanime/cli/config.py index ec1398f..4e23a51 100644 --- a/fastanime/cli/config.py +++ b/fastanime/cli/config.py @@ -9,7 +9,7 @@ from ..constants import ( USER_DATA_PATH, USER_VIDEOS_DIR, USER_WATCH_HISTORY_PATH, - S_PLATFORM + S_PLATFORM, ) from ..libs.rofi import Rofi @@ -52,6 +52,7 @@ class Config(object): "quality": "1080", "recent": "50", "rofi_theme": "", + "rofi_theme_preview": "", "rofi_theme_confirm": "", "rofi_theme_input": "", "server": "top", @@ -105,10 +106,12 @@ class Config(object): self.rofi_theme_confirm = self.get_rofi_theme_confirm() self.rofi_theme_input = self.get_rofi_theme_input() self.rofi_theme = self.get_rofi_theme() + self.rofi_theme_preview = self.get_rofi_theme_preview() Rofi.rofi_theme_confirm = self.rofi_theme_confirm Rofi.rofi_theme_input = self.rofi_theme_input Rofi.rofi_theme = self.rofi_theme + Rofi.rofi_theme_preview = self.rofi_theme_preview self.server = self.get_server() self.skip = self.get_skip() @@ -235,6 +238,9 @@ class Config(object): def get_rofi_theme(self): return self.configparser.get("general", "rofi_theme") + def get_rofi_theme_preview(self): + return self.configparser.get("general", "rofi_theme_preview") + def get_rofi_theme_input(self): return self.configparser.get("general", "rofi_theme_input") @@ -380,6 +386,8 @@ use_rofi = {self.use_rofi} # by the way i recommend getting the rofi themes from this project; rofi_theme = {self.rofi_theme} +rofi_theme = {self.rofi_theme_preview} + rofi_theme_input = {self.rofi_theme_input} rofi_theme_confirm = {self.rofi_theme_confirm} diff --git a/fastanime/libs/rofi/__init__.py b/fastanime/libs/rofi/__init__.py index bef920d..4492eeb 100644 --- a/fastanime/libs/rofi/__init__.py +++ b/fastanime/libs/rofi/__init__.py @@ -11,6 +11,7 @@ class RofiApi: ROFI_EXECUTABLE = which("rofi") rofi_theme = "" + rofi_theme_preview = "" rofi_theme_confirm = "" rofi_theme_input = "" @@ -21,8 +22,8 @@ class RofiApi: raise Exception("Rofi not found") args = [self.ROFI_EXECUTABLE] - if self.rofi_theme: - args.extend(["-no-config", "-theme", self.rofi_theme]) + if self.rofi_theme_preview: + args.extend(["-no-config", "-theme", self.rofi_theme_preview]) args.extend(["-p", f"{prompt_text.title()}", "-i", "-show-icons", "-dmenu"]) result = subprocess.run( args,