Merge settings window to main #23
@@ -19,20 +19,20 @@ Searcher {
|
||||
function preview(path: string): void {
|
||||
previewPath = path;
|
||||
if (Config.general.color.schemeGeneration)
|
||||
Quickshell.execDetached(["sh", "-c", `zshell-cli scheme generate --image-path ${previewPath} --scheme ${Config.colors.schemeType} --mode ${Config.general.color.mode}`]);
|
||||
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--image-path", `${previewPath}`, "--scheme", `${Config.colors.schemeType}`, "--mode", `${Config.general.color.mode}`]);
|
||||
showPreview = true;
|
||||
}
|
||||
|
||||
function setWallpaper(path: string): void {
|
||||
actualCurrent = path;
|
||||
WallpaperPath.currentWallpaperPath = path;
|
||||
Quickshell.execDetached(["sh", "-c", `zshell-cli wallpaper lockscreen --input-image=${root.actualCurrent} --output-path=${Paths.state}/lockscreen_bg.png --blur-amount=${Config.lock.blurAmount}`]);
|
||||
Quickshell.execDetached(["zshell-cli", "wallpaper", "lockscreen", "--input-image", `${root.actualCurrent}`, "--output-path", `${Paths.state}/lockscreen_bg.png`, "--blur-amount", `${Config.lock.blurAmount}`]);
|
||||
}
|
||||
|
||||
function stopPreview(): void {
|
||||
showPreview = false;
|
||||
if (Config.general.color.schemeGeneration)
|
||||
Quickshell.execDetached(["sh", "-c", `zshell-cli scheme generate --image-path ${root.actualCurrent} --scheme ${Config.colors.schemeType} --mode ${Config.general.color.mode}`]);
|
||||
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--image-path", `${root.actualCurrent}`, "--scheme", `${Config.colors.schemeType}`, "--mode", `${Config.general.color.mode}`]);
|
||||
}
|
||||
|
||||
extraOpts: useFuzzy ? ({}) : ({
|
||||
|
||||
@@ -2,6 +2,8 @@ import typer
|
||||
import json
|
||||
import shutil
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader, StrictUndefined, Undefined
|
||||
from typing import Any, Optional, Tuple
|
||||
@@ -240,6 +242,53 @@ def generate(
|
||||
|
||||
return is_dark
|
||||
|
||||
def apply_gtk_mode(mode: str) -> None:
|
||||
mode = mode.lower()
|
||||
preference = "prefer-dark" if mode == "dark" else "prefer-light"
|
||||
|
||||
try:
|
||||
subprocess.run(
|
||||
[
|
||||
"gsettings",
|
||||
"set",
|
||||
"org.gnome.desktop.interface",
|
||||
"color-scheme",
|
||||
preference,
|
||||
],
|
||||
check=False,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def apply_qt_mode(mode: str, home: str) -> None:
|
||||
mode = mode.lower()
|
||||
qt_conf = Path(home) / ".config/qt6ct/qt6ct.conf"
|
||||
|
||||
if not qt_conf.exists():
|
||||
return
|
||||
|
||||
try:
|
||||
text = qt_conf.read_text(encoding="utf-8")
|
||||
except OSError:
|
||||
return
|
||||
|
||||
target = "Dark.colors" if mode == "dark" else "Light.colors"
|
||||
|
||||
new_text, count = re.subn(
|
||||
r"^(color_scheme_path=.*?)(?:Light|Dark)\.colors\s*$",
|
||||
rf"\1{target}",
|
||||
text,
|
||||
flags=re.MULTILINE,
|
||||
)
|
||||
|
||||
if count > 0 and new_text != text:
|
||||
try:
|
||||
qt_conf.write_text(new_text, encoding="utf-8")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def build_template_context(
|
||||
*,
|
||||
colors: dict[str, str],
|
||||
@@ -440,6 +489,10 @@ def generate(
|
||||
|
||||
colors = generate_color_scheme(seed, effective_mode, scheme_class)
|
||||
|
||||
if smart and not preset:
|
||||
apply_gtk_mode(mode)
|
||||
apply_qt_mode(mode, HOME)
|
||||
|
||||
output_dict = {
|
||||
"name": name,
|
||||
"flavor": flavor,
|
||||
|
||||
Reference in New Issue
Block a user