From 5d5d9575b60852d4980a3841560cc6e305de1bdf Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Wed, 18 Feb 2026 23:39:06 +0100 Subject: [PATCH] general ipc calls --- Helpers/Wallpapers.qml | 2 +- cli/src/zshell/subcommands/shell.py | 11 +++++++++++ cli/src/zshell/subcommands/wallpaper.py | 26 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Helpers/Wallpapers.qml b/Helpers/Wallpapers.qml index 1902bbe..4fe6d8c 100644 --- a/Helpers/Wallpapers.qml +++ b/Helpers/Wallpapers.qml @@ -20,7 +20,7 @@ Searcher { actualCurrent = path; WallpaperPath.currentWallpaperPath = path; Wallust.generateColors(WallpaperPath.currentWallpaperPath); - Quickshell.execDetached(["sh", "-c", `python3 ${Quickshell.shellPath("scripts/LockScreenBg.py")} --input_image=${root.actualCurrent} --output_path=${Paths.state}/lockscreen_bg.png --blur_amount=${Config.lock.blurAmount}`]); + Quickshell.execDetached(["sh", "-c", `zshell-cli wallpaper lockscreen --input_image=${root.actualCurrent} --output_path=${Paths.state}/lockscreen_bg.png --blur_amount=${Config.lock.blurAmount}`]); } function preview(path: string): void { diff --git a/cli/src/zshell/subcommands/shell.py b/cli/src/zshell/subcommands/shell.py index c503891..d53e23d 100644 --- a/cli/src/zshell/subcommands/shell.py +++ b/cli/src/zshell/subcommands/shell.py @@ -5,22 +5,33 @@ args = ["qs", "-c", "zshell"] app = typer.Typer() + @app.command() def kill(): subprocess.run(args + ["kill"], check=True) + @app.command() def start(no_daemon: bool = False): subprocess.run(args + ([] if no_daemon else ["-d"]), check=True) + @app.command() def show(): subprocess.run(args + ["ipc"] + ["show"], check=True) + @app.command() def log(): subprocess.run(args + ["log"], check=True) + @app.command() def lock(): subprocess.run(args + ["ipc"] + ["call"] + ["lock"] + ["lock"], check=True) + + +@app.command() +def call(target: str, method: str, method_args: list[str] = typer.Argument(None)): + subprocess.run(args + ["ipc"] + ["call"] + [target] + + [method] + method_args, check=True) diff --git a/cli/src/zshell/subcommands/wallpaper.py b/cli/src/zshell/subcommands/wallpaper.py index 42256c6..946926d 100644 --- a/cli/src/zshell/subcommands/wallpaper.py +++ b/cli/src/zshell/subcommands/wallpaper.py @@ -1,6 +1,8 @@ import subprocess import typer +from typing import Annotated +from PIL import Image, ImageFilter from pathlib import Path args = ["qs", "-c", "zshell"] @@ -12,3 +14,27 @@ app = typer.Typer() def set(wallpaper: Path): subprocess.run(args + ["ipc"] + ["call"] + ["wallpaper"] + ["set"] + [wallpaper], check=True) + + +@app.command() +def lockscreen( + input_image: Annotated[ + Path, + typer.Option(), + ], + output_path: Annotated[ + Path, + typer.Option(), + ], + blur_amount: int = 20 +): + img = Image.open(input_image) + size = img.size + if (size[0] < 3840 or size[1] < 2160): + img = img.resize((size[0] // 2, size[1] // 2), Image.NEAREST) + else: + img = img.resize((size[0] // 4, size[1] // 4), Image.NEAREST) + + img = img.filter(ImageFilter.GaussianBlur(blur_amount)) + + img.save(output_path, "PNG")