Settings window #20

Merged
Zacharias-Brohn merged 83 commits from settingsWindow into main 2026-03-06 23:27:24 +01:00
4 changed files with 44 additions and 12 deletions
Showing only changes of commit 52cf956323 - Show all commits
+17 -1
View File
@@ -6,11 +6,27 @@ JsonObject {
{ {
name: "Calculator", name: "Calculator",
icon: "calculate", icon: "calculate",
description: "Do simple math equations (powered by Qalc)", description: "Do simple math equations",
command: ["autocomplete", "calc"], command: ["autocomplete", "calc"],
enabled: true, enabled: true,
dangerous: false dangerous: false
}, },
{
name: "Light",
icon: "light_mode",
description: "Change to light mode",
command: ["setMode", "light"],
enabled: true,
dangerous: false
},
{
name: "Dark",
icon: "dark_mode",
description: "Change to dark mode",
command: ["setMode", "dark"],
enabled: true,
dangerous: false
},
{ {
name: "Wallpaper", name: "Wallpaper",
icon: "image", icon: "image",
+2 -2
View File
@@ -19,7 +19,7 @@ Searcher {
function preview(path: string): void { function preview(path: string): void {
previewPath = path; previewPath = path;
if (Config.general.color.schemeGeneration) if (Config.general.color.schemeGeneration)
Quickshell.execDetached(["sh", "-c", `zshell-cli scheme generate --image-path ${previewPath} --thumbnail-path ${Paths.cache}/imagecache/thumbnail.jpg --output ${Paths.state}/scheme.json --scheme ${Config.colors.schemeType} --mode ${Config.general.color.mode}`]); Quickshell.execDetached(["sh", "-c", `zshell-cli scheme generate --image-path ${previewPath} --scheme ${Config.colors.schemeType} --mode ${Config.general.color.mode}`]);
showPreview = true; showPreview = true;
} }
@@ -34,7 +34,7 @@ Searcher {
function stopPreview(): void { function stopPreview(): void {
showPreview = false; showPreview = false;
if (Config.general.color.schemeGeneration) if (Config.general.color.schemeGeneration)
Quickshell.execDetached(["sh", "-c", `zshell-cli scheme generate --image-path ${root.actualCurrent} --thumbnail-path ${Paths.cache}/imagecache/thumbnail.jpg --output ${Paths.state}/scheme.json --scheme ${Config.colors.schemeType} --mode ${Config.general.color.mode}`]); Quickshell.execDetached(["sh", "-c", `zshell-cli scheme generate --image-path ${root.actualCurrent} --scheme ${Config.colors.schemeType} --mode ${Config.general.color.mode}`]);
} }
extraOpts: useFuzzy ? ({}) : ({ extraOpts: useFuzzy ? ({}) : ({
+1 -1
View File
@@ -42,7 +42,7 @@ Searcher {
list.search.text = `${Config.launcher.actionPrefix}${command[1]} `; list.search.text = `${Config.launcher.actionPrefix}${command[1]} `;
} else if (command[0] === "setMode" && command.length > 1) { } else if (command[0] === "setMode" && command.length > 1) {
list.visibilities.launcher = false; list.visibilities.launcher = false;
Colours.setMode(command[1]); DynamicColors.setMode(command[1]);
} else { } else {
list.visibilities.launcher = false; list.visibilities.launcher = false;
Quickshell.execDetached(command); Quickshell.execDetached(command);
+24 -8
View File
@@ -5,6 +5,7 @@ import json
from zshell.utils.schemepalettes import PRESETS from zshell.utils.schemepalettes import PRESETS
from pathlib import Path from pathlib import Path
from PIL import Image from PIL import Image
import os
from materialyoucolor.quantize import QuantizeCelebi from materialyoucolor.quantize import QuantizeCelebi
from materialyoucolor.score.score import Score from materialyoucolor.score.score import Score
from materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors from materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors
@@ -30,9 +31,6 @@ def generate(
# output (required) # output (required)
output: Path = typer.Option(..., help="Output JSON path.") output: Path = typer.Option(..., help="Output JSON path.")
): ):
if preset is None and image_path is None:
raise typer.BadParameter(
"Either --image-path or --preset must be provided.")
if preset is not None and image_path is not None: if preset is not None and image_path is not None:
raise typer.BadParameter( raise typer.BadParameter(
@@ -60,6 +58,18 @@ def generate(
case _: case _:
from materialyoucolor.scheme.scheme_fruit_salad import SchemeFruitSalad as Scheme from materialyoucolor.scheme.scheme_fruit_salad import SchemeFruitSalad as Scheme
OUTPUT = Path(f"os.getenv('HOME')" + ".local/state/zshell/scheme.json")
THUMB_PATH = Path(f"os.getenv('HOME')" +
".cache/zshell/imagecache/thumbnail.jpg")
WALL_DIR_PATH = Path(f"os.getenv('HOME')" +
".local/state/zshell/wallpaper_path.json")
WALL_PATH = Path()
with WALL_DIR_PATH.open() as f:
line = f.readline
WALL_PATH = line
def generate_thumbnail(image_path, thumbnail_path, size=(128, 128)): def generate_thumbnail(image_path, thumbnail_path, size=(128, 128)):
thumbnail_file = Path(thumbnail_path) thumbnail_file = Path(thumbnail_path)
@@ -115,9 +125,15 @@ def generate(
seed = seed_from_preset(preset) seed = seed_from_preset(preset)
colors = generate_color_scheme(seed, mode) colors = generate_color_scheme(seed, mode)
name, flavor = preset.split(":") name, flavor = preset.split(":")
else: elif image_path:
generate_thumbnail(image_path, str(thumbnail_path)) generate_thumbnail(image_path, str(THUMB_PATH))
seed = seed_from_image(thumbnail_path) seed = seed_from_image(THUMB_PATH)
colors = generate_color_scheme(seed, mode)
name = "dynamic"
flavor = "default"
elif image_path is None and mode is not None:
generate_thumbnail(WALL_PATH, str(THUMB_PATH))
seed = seed_from_image(THUMB_PATH)
colors = generate_color_scheme(seed, mode) colors = generate_color_scheme(seed, mode)
name = "dynamic" name = "dynamic"
flavor = "default" flavor = "default"
@@ -130,8 +146,8 @@ def generate(
"colors": colors "colors": colors
} }
output.parent.mkdir(parents=True, exist_ok=True) OUTPUT.parent.mkdir(parents=True, exist_ok=True)
with open(output, "w") as f: with open(OUTPUT, "w") as f:
json.dump(output_dict, f, indent=4) json.dump(output_dict, f, indent=4)
except Exception as e: except Exception as e:
print(f"Error: {e}") print(f"Error: {e}")