Skip to content

Commit

Permalink
refactor(shader): remove _resolve_path_after_intermediate_steps
Browse files Browse the repository at this point in the history
  • Loading branch information
loqusion committed Apr 8, 2024
1 parent 93e659f commit 64f024f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/hyprshade/shader/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ def __init__(self, shader_name_or_path: str, config: Config | None):
self._config = config

def on(self) -> None:
path = self._resolve_path_after_intermediate_steps()
logging.debug(f"Turning on shader '{self._name}' at '{path}'")
hyprctl.set_screen_shader(path)
source_path = self._resolve_path()
_, source_path_extension = os.path.splitext(os.path.basename(source_path))
if source_path_extension.strip(".") in TEMPLATE_EXTENSIONS:
rendered_path = self._render_template(source_path)
else:
rendered_path = source_path
logging.debug(f"Turning on shader '{self._name}' at '{rendered_path}'")
hyprctl.set_screen_shader(rendered_path)

@staticmethod
def off() -> None:
Expand All @@ -104,13 +109,6 @@ def current() -> PureShader | None:
path = hyprctl.get_screen_shader()
return None if path is None else PureShader(path)

def _resolve_path_after_intermediate_steps(self) -> str:
path = self._resolve_path()
_, extension = os.path.splitext(os.path.basename(path))
if extension.strip(".") in TEMPLATE_EXTENSIONS:
return self._render_template(path)
return path

def _render_template(self, path: str) -> str:
with open(path) as f:
variables = (
Expand Down

0 comments on commit 64f024f

Please sign in to comment.