Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebace10767 | ||
|
|
2a41cde6f5 | ||
|
|
de9b863f3f | ||
|
|
b6d0da4679 | ||
|
|
ad740ef631 |
No files matched your search
+3
-2
@@ -35,11 +35,12 @@
|
||||
"easyeffects": "Dashboard Media tab equalizer only; writes the glassmxrph_eq output preset and starts EasyEffects in service mode on apply",
|
||||
"wttr.in (network)": "Weather desktop widget only; fetched every 30 minutes while a weather widget exists",
|
||||
"Nerd Font": "Icon glyphs in Settings (any installed Nerd Font, e.g. Symbols Nerd Font); letters are used otherwise",
|
||||
"nvidia-smi": "Read-only NVIDIA GPU telemetry through the host driver tool; other metrics do not require it"
|
||||
"nvidia-smi": "Read-only NVIDIA GPU telemetry through the host driver tool; other metrics do not require it",
|
||||
"BiRefNet + onnxruntime/opencv/numpy/pillow": "Outline wallpaper transitions only; set GLASSMXRPH_WALLFX_PYTHON (an interpreter with those modules) and GLASSMXRPH_WALLFX_MODEL (the BiRefNet ONNX file). The Nix package sets both; without them every change uses colonies"
|
||||
},
|
||||
"development": [
|
||||
"qmllint",
|
||||
"qsb from Qt Shader Tools (only to rebuild lock/shaders/*.qsb: scripts/build-shaders)",
|
||||
"qsb from Qt Shader Tools (only to rebuild lock/shaders and wallpaper/shaders *.qsb: scripts/build-shaders)",
|
||||
"node (configuration, dock and launcher logic tests)",
|
||||
"QtTest (tray, dock, launcher, settings, media and Control Center input tests only)",
|
||||
"Python 3 with dbus-python and PyGObject (isolated tray and MPRIS fixtures)",
|
||||
|
||||
@@ -16,7 +16,7 @@ Open Settings → Wallpaper → Open wallpaper picker, or run:
|
||||
./scripts/glassmxrph wallpaper
|
||||
```
|
||||
|
||||
The centered carousel follows the current Super+Shift+W picker's visual concept and runs entirely inside glassMxrph. Search local images, select an output, browse with arrow keys and apply with Enter or double-click. History records the last 50 selections. Escape or an outside click closes it.
|
||||
The picker drawer shows the wallpapers as a justified gallery: every thumbnail keeps its own aspect ratio and each row fills the width. Search local images, select an output, browse with the arrow keys and apply with Enter or a click. ✦ marks wallpapers whose subject outline is drawn first when changing to them. History records the last 50 selections. Escape or an outside click closes it.
|
||||
|
||||
Configure image directories in Wallpaper settings; the default search directory is ~/Pictures/Wallpapers. Select the Native backend when replacing Serpantinum. New configurations default to Native; existing explicit backend preferences are preserved.
|
||||
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
{ lib, stdenvNoCC, makeWrapper, quickshell, qt6, nodejs, source }:
|
||||
{ lib, stdenvNoCC, makeWrapper, quickshell, qt6, nodejs, python3, fetchurl, source }:
|
||||
let
|
||||
# Outline wallpaper transitions (quickshell/helpers/wallfx.py): BiRefNet lite
|
||||
# finds a wallpaper's subject, run on the CPU through onnxruntime.
|
||||
wallfxPython = python3.withPackages (ps: [ ps.numpy ps.opencv4 ps.pillow ps.onnxruntime ]);
|
||||
wallfxModel = fetchurl {
|
||||
url = "https://github.com/danielgatis/rembg/releases/download/v0.0.0/BiRefNet-general-bb_swin_v1_tiny-epoch_232.onnx";
|
||||
sha256 = "0crky386fm0268hy5qglpqv1d5p5n6pv0phahxbsawpmfr1h402n";
|
||||
};
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "glassMxrph";
|
||||
version = "0.2.0";
|
||||
@@ -12,7 +21,9 @@ stdenvNoCC.mkDerivation {
|
||||
cp -r quickshell scripts tests docs dependencies.json README.md $out/share/glassMxrph/
|
||||
makeWrapper $out/share/glassMxrph/scripts/glassmxrph $out/bin/glassmxrph \
|
||||
--prefix PATH : ${lib.makeBinPath [ quickshell ]} \
|
||||
--prefix QT_PLUGIN_PATH : ${qt6.qtimageformats}/${qt6.qtbase.qtPluginPrefix}
|
||||
--prefix QT_PLUGIN_PATH : ${qt6.qtimageformats}/${qt6.qtbase.qtPluginPrefix} \
|
||||
--set-default GLASSMXRPH_WALLFX_PYTHON ${wallfxPython}/bin/python3 \
|
||||
--set-default GLASSMXRPH_WALLFX_MODEL ${wallfxModel}
|
||||
'';
|
||||
meta = {
|
||||
description = "Modular glass desktop shell for Quickshell and Hyprland";
|
||||
|
||||
@@ -147,7 +147,8 @@
|
||||
"backend": "native",
|
||||
"command": [],
|
||||
"providerPaths": {},
|
||||
"history": []
|
||||
"history": [],
|
||||
"outlineExclude": []
|
||||
},
|
||||
"controlCenter": {
|
||||
"version": 2,
|
||||
|
||||
@@ -92,6 +92,41 @@ def apply(req):
|
||||
else:raise ValueError('No active wallpaper provider')
|
||||
return {'backend':backend,'path':str(path),'providerPath':str(path)}
|
||||
|
||||
def image_size(path):
|
||||
"""(width, height) from the file header, or None. Standard library only:
|
||||
the picker lays thumbnails out by aspect ratio before any is decoded."""
|
||||
import struct
|
||||
try:
|
||||
with open(path,'rb') as f:
|
||||
head=f.read(32)
|
||||
if head[:8]==b'\x89PNG\r\n\x1a\n':
|
||||
return struct.unpack('>II',head[16:24])
|
||||
if head[:2]==b'BM':
|
||||
w,h=struct.unpack('<ii',head[18:26]);return (abs(w),abs(h))
|
||||
if head[:4]==b'RIFF' and head[8:12]==b'WEBP':
|
||||
kind=head[12:16]
|
||||
if kind==b'VP8 ':
|
||||
w,h=struct.unpack('<HH',head[26:30]);return (w&0x3fff,h&0x3fff)
|
||||
if kind==b'VP8L':
|
||||
b=head[21:25];return (1+(((b[1]&0x3f)<<8)|b[0]),1+(((b[3]&0xf)<<10)|(b[2]<<2)|((b[1]&0xc0)>>6)))
|
||||
if kind==b'VP8X':
|
||||
return (1+int.from_bytes(head[24:27],'little'),1+int.from_bytes(head[27:30],'little'))
|
||||
return None
|
||||
if head[:2]==b'\xff\xd8':
|
||||
f.seek(2)
|
||||
while True:
|
||||
marker=f.read(2)
|
||||
if len(marker)<2 or marker[0]!=0xff:return None
|
||||
while marker[1]==0xff:marker=marker[:1]+f.read(1)
|
||||
if marker[1] in (0xd8,0x01) or 0xd0<=marker[1]<=0xd7:continue
|
||||
length=struct.unpack('>H',f.read(2))[0]
|
||||
if marker[1] in (0xc0,0xc1,0xc2,0xc3,0xc5,0xc6,0xc7,0xc9,0xca,0xcb,0xcd,0xce,0xcf):
|
||||
h,w=struct.unpack('>xHH',f.read(5));return (w,h)
|
||||
f.seek(length-2,1)
|
||||
except (OSError,struct.error):
|
||||
return None
|
||||
return None
|
||||
|
||||
def scan(req):
|
||||
found={};errors=[]
|
||||
for directory in (req.get('directories') or [str(Path.home()/'Pictures/Wallpapers')]):
|
||||
@@ -99,7 +134,8 @@ def scan(req):
|
||||
try:
|
||||
for entry in base.iterdir():
|
||||
if entry.is_file() and entry.suffix.lower() in IMAGES:
|
||||
resolved=entry.resolve();found[str(resolved)]={'path':str(resolved),'url':resolved.as_uri(),'name':entry.name}
|
||||
resolved=entry.resolve();size=image_size(resolved)
|
||||
found[str(resolved)]={'path':str(resolved),'url':resolved.as_uri(),'name':entry.name,'width':size[0] if size else 0,'height':size[1] if size else 0}
|
||||
if len(found)>=1000:break
|
||||
except OSError as error:errors.append(str(error))
|
||||
if len(found)>=1000:break
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Outline maps for the wallpaper change (wallpaper/shaders/colonies.frag, mode 1).
|
||||
|
||||
When a new wallpaper has a clear subject, the change draws the subject's
|
||||
outline, fills it in from that outline, and then grows the rest of the picture
|
||||
out of it. This helper finds the subject (BiRefNet, through onnxruntime) and
|
||||
bakes two RGB maps in the image's own space; the shader only reads them.
|
||||
|
||||
field.png R depth inside the subject: 0 on its outline, 1 at its deepest
|
||||
G signed distance to the outline, +-SD_RANGE map px, 0.5 on it
|
||||
line.png R position along the outline (two pens from the top), 0 = no line
|
||||
G/B order in which the outside arrives, 16 bits, smooth
|
||||
|
||||
Maps are cached per image (path, size and mtime). Commands, each printing one
|
||||
JSON object:
|
||||
|
||||
choose IMG {"kind": "outline", "field", "line"} when cached maps exist,
|
||||
{"kind": "colonies", "pending": true} when IMG is not
|
||||
processed yet, {"kind": "colonies"} when it has no subject.
|
||||
Uses only the standard library, so it answers at once.
|
||||
status IMG... {IMG: "outline" | "colonies" | "pending"}; standard library only.
|
||||
warm IMG... processes every image not cached yet; one warm at a time.
|
||||
outline IMG [--force]
|
||||
|
||||
Requires GLASSMXRPH_WALLFX_MODEL (BiRefNet ONNX) and numpy, opencv, pillow and
|
||||
onnxruntime in the interpreter running this file.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
CACHE = os.path.join(os.environ.get("XDG_CACHE_HOME") or os.path.expanduser("~/.cache"), "glassMxrph", "wallfx")
|
||||
MODEL = os.environ.get("GLASSMXRPH_WALLFX_MODEL", "")
|
||||
MAP_MAX = 1280 # long side of the maps; the shader interpolates them
|
||||
SD_RANGE = 16.0 # signed distance kept within +-16 map px of the outline
|
||||
EXTS = (".jpg", ".jpeg", ".png", ".webp", ".bmp")
|
||||
|
||||
|
||||
def key(img):
|
||||
st = os.stat(img)
|
||||
return hashlib.sha1(f"{os.path.realpath(img)}|{st.st_size}|{int(st.st_mtime)}".encode()).hexdigest()[:16]
|
||||
|
||||
|
||||
def cached(img):
|
||||
"""(field, line) if IMG has cached maps, False if it has no subject, None if unprocessed."""
|
||||
base = os.path.join(CACHE, key(img))
|
||||
try:
|
||||
with open(base + ".json") as f:
|
||||
meta = json.load(f)
|
||||
except (OSError, ValueError):
|
||||
return None
|
||||
if not meta.get("ok"):
|
||||
return False
|
||||
field, line = base + "-field.png", base + "-line.png"
|
||||
return (field, line) if os.path.exists(field) and os.path.exists(line) else None
|
||||
|
||||
|
||||
# ───────────────────────────── subject mask ─────────────────────────────
|
||||
|
||||
_session = None
|
||||
|
||||
|
||||
def mask_of(im):
|
||||
"""BiRefNet's foreground probability for a PIL RGB image, as float32 0..1."""
|
||||
global _session
|
||||
import numpy as np
|
||||
import onnxruntime as ort
|
||||
from PIL import Image
|
||||
if _session is None:
|
||||
opts = ort.SessionOptions()
|
||||
opts.intra_op_num_threads = max(1, (os.cpu_count() or 2) // 2) # leave the desktop room
|
||||
_session = ort.InferenceSession(MODEL, opts, providers=["CPUExecutionProvider"])
|
||||
x = np.asarray(im.resize((1024, 1024), Image.Resampling.LANCZOS), np.float32)
|
||||
x /= max(float(x.max()), 1e-6)
|
||||
x = (x - np.array([0.485, 0.456, 0.406], np.float32)) / np.array([0.229, 0.224, 0.225], np.float32)
|
||||
x = x.transpose(2, 0, 1)[None].astype(np.float32)
|
||||
out = _session.run(None, {_session.get_inputs()[0].name: x})[0][0, 0]
|
||||
p = 1.0 / (1.0 + np.exp(-out))
|
||||
p = (p - p.min()) / max(float(p.max() - p.min()), 1e-6)
|
||||
m = Image.fromarray((p * 255).astype(np.uint8)).resize(im.size, Image.Resampling.LANCZOS)
|
||||
return np.asarray(m, np.float32) / 255.0
|
||||
|
||||
|
||||
# ───────────────────────────── maps ─────────────────────────────
|
||||
|
||||
def value_noise(rng, w, h, scale):
|
||||
import numpy as np
|
||||
lat = rng.random((int(h / scale) + 3, int(w / scale) + 3))
|
||||
xs, ys = np.arange(w) / scale, np.arange(h) / scale
|
||||
ix, iy = xs.astype(int), ys.astype(int)
|
||||
fx, fy = xs - ix, ys - iy
|
||||
fx, fy = fx * fx * (3 - 2 * fx), fy * fy * (3 - 2 * fy)
|
||||
top = lat[iy][:, ix] * (1 - fx) + lat[iy][:, ix + 1] * fx
|
||||
bot = lat[iy + 1][:, ix] * (1 - fx) + lat[iy + 1][:, ix + 1] * fx
|
||||
return top * (1 - fy)[:, None] + bot * fy[:, None]
|
||||
|
||||
|
||||
def write_png(path, rgb):
|
||||
"""Atomic: the shell may be reading the previous maps while these are written.
|
||||
RGB without alpha, so Qt does not premultiply the numbers."""
|
||||
from PIL import Image
|
||||
tmp = f"{path}.{os.getpid()}.tmp.png"
|
||||
Image.fromarray(rgb, "RGB").save(tmp)
|
||||
os.replace(tmp, path)
|
||||
|
||||
|
||||
def build(img, force=False):
|
||||
"""Bake IMG's maps; returns (field, line) or None when it has no clear subject."""
|
||||
import fcntl
|
||||
os.makedirs(CACHE, exist_ok=True)
|
||||
base = os.path.join(CACHE, key(img))
|
||||
with open(base + ".lock", "w") as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX) # one bake per image at a time
|
||||
if not force:
|
||||
hit = cached(img)
|
||||
if hit is not None:
|
||||
return hit or None
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
im = Image.open(img).convert("RGB")
|
||||
im.thumbnail((MAP_MAX, MAP_MAX))
|
||||
mask_path = base + "-mask.png" # the slow part; kept across --force
|
||||
if os.path.exists(mask_path):
|
||||
m = np.asarray(Image.open(mask_path).convert("L").resize(im.size), np.float32) / 255.0
|
||||
else:
|
||||
m = mask_of(im)
|
||||
Image.fromarray((m * 255).astype(np.uint8)).save(mask_path)
|
||||
h, w = m.shape
|
||||
b = (m > 0.5).astype(np.uint8)
|
||||
# Specks of foreground would be outlined as dots all over the screen.
|
||||
n, lab, stats, _ = cv2.connectedComponentsWithStats(b, connectivity=8)
|
||||
keep = np.zeros(n, bool)
|
||||
keep[1:] = stats[1:, cv2.CC_STAT_AREA] >= 0.002 * w * h
|
||||
b = keep[lab].astype(np.uint8)
|
||||
cover = float(b.mean())
|
||||
unsure = float(((m > 0.1) & (m < 0.9)).mean())
|
||||
# A subject takes part of the picture, not nearly all of it nor a crumb,
|
||||
# and the model is sure where it ends.
|
||||
ok = 0.008 <= cover <= 0.72 and unsure <= 0.06
|
||||
meta = {"img": img, "ok": ok, "cover": round(cover, 3), "unsure": round(unsure, 3)}
|
||||
if ok:
|
||||
din = cv2.distanceTransform(b, cv2.DIST_L2, 5)
|
||||
dout = cv2.distanceTransform(1 - b, cv2.DIST_L2, 5)
|
||||
sd = dout - din # > 0 outside
|
||||
inner = np.clip(din / max(float(np.percentile(din[b > 0], 99)), 1.0), 0, 1)
|
||||
|
||||
# Outside order: distance from the subject, bent by noise so the front
|
||||
# is not a plain offset of the silhouette, then ranked by area.
|
||||
rng = np.random.default_rng(int(key(img)[:8], 16))
|
||||
noise = 0.6 * value_noise(rng, w, h, w / 9.0) + 0.4 * value_noise(rng, w, h, w / 28.0)
|
||||
warped = dout * (0.75 + 0.5 * noise) + noise * 0.08 * max(w, h)
|
||||
outside = b == 0
|
||||
order = np.zeros((h, w), np.float32)
|
||||
vals = warped[outside]
|
||||
rank = np.empty(vals.size)
|
||||
rank[np.argsort(vals, kind="stable")] = np.arange(vals.size)
|
||||
order[outside] = rank / max(vals.size - 1, 1)
|
||||
order = cv2.GaussianBlur(order, (0, 0), 4.0)
|
||||
|
||||
# Along the outline: each contour starts at its top point, drawn by two
|
||||
# pens going round in opposite directions that meet on the far side.
|
||||
edge = np.zeros((h, w), np.uint8)
|
||||
param = np.zeros((h, w), np.float32)
|
||||
contours, _ = cv2.findContours(b, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
|
||||
for c in contours:
|
||||
if len(c) < 40 or abs(cv2.contourArea(c)) < 0.0008 * w * h:
|
||||
continue # tiny holes get no line
|
||||
c = c[:, 0, :]
|
||||
seg = np.sqrt((np.diff(c, axis=0, append=c[:1]) ** 2).sum(1))
|
||||
s = np.concatenate([[0], np.cumsum(seg)[:-1]])
|
||||
total = s[-1] + seg[-1]
|
||||
s = (s - s[np.argmin(c[:, 1])]) % total
|
||||
p = np.minimum(s, total - s) / (total / 2)
|
||||
# Where the subject runs off the picture its contour follows the
|
||||
# border: that is not an outline.
|
||||
p[(c[:, 0] <= 1) | (c[:, 0] >= w - 2) | (c[:, 1] <= 1) | (c[:, 1] >= h - 2)] = -1
|
||||
edge[c[:, 1], c[:, 0]] = 1
|
||||
param[c[:, 1], c[:, 0]] = p
|
||||
line = np.zeros((h, w), np.uint8)
|
||||
if edge.any():
|
||||
_, labels = cv2.distanceTransformWithLabels(1 - edge, cv2.DIST_L2, 5,
|
||||
labelType=cv2.DIST_LABEL_PIXEL)
|
||||
ys, xs = np.nonzero(edge)
|
||||
table = np.concatenate([[0], param[ys, xs]])
|
||||
near = np.abs(sd) < SD_RANGE
|
||||
v = table[labels[near]]
|
||||
line[near] = np.where(v < 0, 0, np.clip(v * 255, 1, 255)).astype(np.uint8)
|
||||
|
||||
field = np.zeros((h, w, 3), np.uint8)
|
||||
field[..., 0] = np.clip(inner * 255, 0, 255)
|
||||
field[..., 1] = np.clip((sd + SD_RANGE) / (2 * SD_RANGE) * 255, 0, 255)
|
||||
q = np.clip(order * 65535.0 + 0.5, 0, 65535).astype(np.uint16)
|
||||
lines = np.zeros((h, w, 3), np.uint8)
|
||||
lines[..., 0] = line
|
||||
lines[..., 1] = q >> 8
|
||||
lines[..., 2] = q & 255
|
||||
write_png(base + "-field.png", field)
|
||||
write_png(base + "-line.png", lines)
|
||||
tmp = f"{base}.json.{os.getpid()}.tmp"
|
||||
with open(tmp, "w") as f:
|
||||
json.dump(meta, f)
|
||||
os.replace(tmp, base + ".json")
|
||||
return (base + "-field.png", base + "-line.png") if ok else None
|
||||
|
||||
|
||||
def warm(paths):
|
||||
import fcntl
|
||||
os.makedirs(CACHE, exist_ok=True)
|
||||
with open(os.path.join(CACHE, ".warm.lock"), "w") as lock:
|
||||
try:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except OSError:
|
||||
return # another warm is already on it
|
||||
for path in paths:
|
||||
if not path.lower().endswith(EXTS) or not os.path.isfile(path):
|
||||
continue
|
||||
try:
|
||||
if cached(path) is None:
|
||||
r = build(path)
|
||||
print(("outline " if r else "colonies ") + path, file=sys.stderr, flush=True)
|
||||
except Exception as e: # one bad file must not stop the rest
|
||||
print(f"error {path}: {e}", file=sys.stderr, flush=True)
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2 or argv[0] not in ("choose", "status", "warm", "outline"):
|
||||
print(__doc__, file=sys.stderr)
|
||||
return 2
|
||||
cmd, rest = argv[0], argv[1:]
|
||||
if cmd == "choose":
|
||||
try:
|
||||
hit = cached(rest[0])
|
||||
except OSError:
|
||||
hit = False
|
||||
if hit:
|
||||
out = {"kind": "outline", "field": hit[0], "line": hit[1]}
|
||||
else:
|
||||
out = {"kind": "colonies", "pending": hit is None and bool(MODEL)}
|
||||
elif cmd == "status":
|
||||
out = {}
|
||||
for path in rest:
|
||||
try:
|
||||
hit = cached(path)
|
||||
except OSError:
|
||||
continue
|
||||
out[path] = "outline" if hit else ("pending" if hit is None else "colonies")
|
||||
elif not MODEL or not os.path.exists(MODEL):
|
||||
print("wallfx: GLASSMXRPH_WALLFX_MODEL is not set or missing", file=sys.stderr)
|
||||
return 1
|
||||
elif cmd == "warm":
|
||||
warm(rest)
|
||||
return 0
|
||||
else:
|
||||
r = build(rest[0], force="--force" in rest)
|
||||
out = {"kind": "outline", "field": r[0], "line": r[1]} if r else {"kind": "colonies"}
|
||||
print(json.dumps(out))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
@@ -96,6 +96,7 @@ function validate(c) {
|
||||
if(!Number.isInteger(c.metrics.interval) || c.metrics.interval<1 || c.metrics.interval>30)throw Error("Invalid metrics geometry or interval");
|
||||
if(!Array.isArray(c.metrics.storagePaths) || c.metrics.storagePaths.length>8 || c.metrics.storagePaths.some(p=>typeof p!=="string" || !p.startsWith("/") || p.includes("\u0000")) || new Set(c.metrics.storagePaths).size!==c.metrics.storagePaths.length || typeof c.metrics.networkInterface!=="string" || !c.metrics.networkInterface || typeof c.metrics.gpu!=="string" || !c.metrics.gpu)throw Error("Invalid metrics sources");
|
||||
if(!Array.isArray(c.wallpaper.history) || c.wallpaper.history.length>50 || c.wallpaper.history.some(p=>typeof p!=="string"))throw Error("Invalid wallpaper history");
|
||||
if(!Array.isArray(c.wallpaper.outlineExclude) || c.wallpaper.outlineExclude.some(p=>typeof p!=="string"))throw Error("Invalid wallpaper outline exclusions");
|
||||
if(typeof c.hyprglass.enabled!=="boolean" || typeof c.hyprglass.layers!=="boolean" || typeof c.hyprglass.effectEnabled!=="boolean")throw Error("Invalid glass toggle");
|
||||
for(const [key,min,max] of [["blur_strength",0,5],["blur_iterations",1,5],["refraction_strength",0,8],["chromatic_aberration",0,1],["fresnel_strength",0,1],["specular_strength",0,1],["edge_thickness",0,.15],["lens_distortion",0,1],["brightness",.2,2],["contrast",.2,2],["saturation",0,2],["vibrancy",0,1],["adaptive_dim",0,1]])if(!Number.isFinite(c.hyprglass.values[key]) || c.hyprglass.values[key]<min || c.hyprglass.values[key]>max)throw Error("Invalid glass "+key);
|
||||
if(!Number.isInteger(c.hyprglass.values.blur_iterations))throw Error("Invalid blur passes");
|
||||
|
||||
@@ -53,6 +53,7 @@ Singleton {
|
||||
if (!ConfigService.ready || !ConfigService.writable || !outputs.length || !outputs[0] || busy)
|
||||
return false;
|
||||
error = "";
|
||||
prepareTransition(path);
|
||||
// Native rendering needs no provider round trip: decode once, then switch
|
||||
// every output in one write so their transitions start together.
|
||||
if (backend === "native" && ["native", "auto"].includes(ConfigService.data.wallpaper.backend)) {
|
||||
@@ -106,6 +107,8 @@ Singleton {
|
||||
onFinished: (request, result) => {
|
||||
if (result.ok) {
|
||||
root.images = result.images;
|
||||
root.warmOutlines(result.images.map(image => image.path));
|
||||
root.refreshOutlineStatus();
|
||||
root.notice = (result.notice || "") + (result.limited ? " Showing the first 1,000 images." : "");
|
||||
} else
|
||||
root.error = result.error;
|
||||
@@ -144,6 +147,104 @@ Singleton {
|
||||
ConfigService.setValue("wallpaper.history",[result.path].concat(ConfigService.data.wallpaper.history.filter(p=>p!==result.path)).slice(0,50));
|
||||
Qt.callLater(root.applyNext);
|
||||
}
|
||||
// Which change a wallpaper gets (wallpaper/shaders/transition.frag): its
|
||||
// subject's outline when helpers/wallfx.py has cached maps for it, colonies
|
||||
// otherwise. Nothing waits for a cut-out: an unprocessed wallpaper gets
|
||||
// colonies now and is processed in the background for next time. The
|
||||
// package sets GLASSMXRPH_WALLFX_PYTHON (numpy, opencv, onnxruntime) and
|
||||
// GLASSMXRPH_WALLFX_MODEL; without them every change is colonies.
|
||||
readonly property string wallfxPython: Quickshell.env("GLASSMXRPH_WALLFX_PYTHON") || ""
|
||||
readonly property bool outlinesAvailable: wallfxPython !== "" && (Quickshell.env("GLASSMXRPH_WALLFX_MODEL") || "") !== ""
|
||||
property var transitions: ({}) // path -> {kind, field, line}
|
||||
property var choosing: []
|
||||
function setTransition(path, plan) {
|
||||
const next = Object.assign({}, transitions);
|
||||
next[path] = plan;
|
||||
transitions = next;
|
||||
}
|
||||
// `ifUnknown`: keep an answer already given in this change (the picker asks
|
||||
// at apply time, every output's background asks again when it switches).
|
||||
function prepareTransition(path, ifUnknown) {
|
||||
if (!path || choosing.includes(path) || (ifUnknown && path in transitions))
|
||||
return;
|
||||
const excluded = ConfigService.ready && ConfigService.data.wallpaper.outlineExclude.includes(path);
|
||||
if (!outlinesAvailable || excluded)
|
||||
return setTransition(path, {kind: "colonies"});
|
||||
const next = Object.assign({}, transitions);
|
||||
delete next[path];
|
||||
transitions = next;
|
||||
choosing = choosing.concat([path]);
|
||||
chooseNext();
|
||||
}
|
||||
function chooseNext() {
|
||||
if (chooseJob.running || !choosing.length)
|
||||
return;
|
||||
chooseJob.path = choosing[0];
|
||||
chooseJob.command = [wallfxPython, Quickshell.shellPath("helpers/wallfx.py"), "choose", choosing[0]];
|
||||
chooseJob.running = true;
|
||||
}
|
||||
function warmOutlines(paths) {
|
||||
if (!outlinesAvailable || warmJob.running || !paths.length)
|
||||
return;
|
||||
warmJob.command = ["nice", "-n", "15", wallfxPython, Quickshell.shellPath("helpers/wallfx.py"), "warm"].concat(paths);
|
||||
warmJob.running = true;
|
||||
}
|
||||
// Session libraries on LD_LIBRARY_PATH (JACK, SANE) can be built against
|
||||
// another glibc than the helper's interpreter: keep them out.
|
||||
Process {
|
||||
id: chooseJob
|
||||
property string path: ""
|
||||
environment: ({LD_LIBRARY_PATH: null})
|
||||
stdout: StdioCollector {
|
||||
id: chooseOutput
|
||||
}
|
||||
onExited: {
|
||||
let plan = {kind: "colonies"};
|
||||
try {
|
||||
plan = JSON.parse(chooseOutput.text);
|
||||
} catch (error) {}
|
||||
const path = chooseJob.path;
|
||||
root.choosing = root.choosing.filter(p => p !== path);
|
||||
root.setTransition(path, plan);
|
||||
if (plan.pending)
|
||||
root.warmOutlines([path]);
|
||||
Qt.callLater(root.chooseNext);
|
||||
}
|
||||
}
|
||||
// Processes uncached wallpapers at low priority (~5 s each on the CPU);
|
||||
// one pass at a time, and the helper skips what is already cached.
|
||||
Process {
|
||||
id: warmJob
|
||||
environment: ({LD_LIBRARY_PATH: null})
|
||||
onExited: root.refreshOutlineStatus()
|
||||
}
|
||||
// Path -> "outline", "colonies" or "pending", for the picker's badges.
|
||||
property var outlineStatus: ({})
|
||||
function refreshOutlineStatus() {
|
||||
if (!outlinesAvailable || !images.length)
|
||||
return;
|
||||
if (statusJob.running)
|
||||
return void (statusJob.again = true);
|
||||
statusJob.command = [wallfxPython, Quickshell.shellPath("helpers/wallfx.py"), "status"].concat(images.map(image => image.path));
|
||||
statusJob.running = true;
|
||||
}
|
||||
Process {
|
||||
id: statusJob
|
||||
property bool again: false
|
||||
environment: ({LD_LIBRARY_PATH: null})
|
||||
stdout: StdioCollector {
|
||||
id: statusOutput
|
||||
}
|
||||
onExited: {
|
||||
try {
|
||||
root.outlineStatus = JSON.parse(statusOutput.text);
|
||||
} catch (error) {}
|
||||
if (statusJob.again) {
|
||||
statusJob.again = false;
|
||||
Qt.callLater(root.refreshOutlineStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Native backgrounds report when their new image has decoded; the reveal
|
||||
// starts on every output together once all of them are ready.
|
||||
property var revealWaiting: ({})
|
||||
|
||||
@@ -116,9 +116,8 @@ Item {
|
||||
}
|
||||
function pickerQuery(text: string): void {input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperSearch").text=text;}
|
||||
function pickerSelect(index: int): bool {
|
||||
const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperCarousel");
|
||||
view.positionViewAtIndex(index,ListView.Contain);input.wait(50);
|
||||
const item=view.itemAtIndex(index);if(!item)return false;
|
||||
ShellState.wallpaperWindow.tileAt(index);input.wait(50);
|
||||
const item=ShellState.wallpaperWindow.tileAt(index);if(!item)return false;
|
||||
input.mouseClick(item,item.width/2,item.height/2);return true;
|
||||
}
|
||||
function pickerScreenshot(path: string): bool {return input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperPickerSurface").grabToImage(result=>result.saveToFile(path));}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import "../services"
|
||||
import "../theme"
|
||||
// A full-size wallpaper that changes with shaders/transition.frag: colonies, or
|
||||
// the new wallpaper's subject outline when helpers/wallfx.py has its maps.
|
||||
// One per output (WallpaperBackground).
|
||||
Item {
|
||||
id: root
|
||||
// The wallpaper to show. Changing it starts a change once the new image
|
||||
// (and its outline maps, if any) are loaded.
|
||||
property string path: ""
|
||||
// false: a change starts as soon as it is ready. true: it emits ready()
|
||||
// and waits for go(), so several outputs can start together.
|
||||
property bool waitForGo: false
|
||||
signal loading()
|
||||
signal ready()
|
||||
// 0..1 while the new wallpaper takes over.
|
||||
property real progress: 0
|
||||
readonly property bool transitioning: incoming.source.toString() !== ""
|
||||
readonly property bool running: reveal.running
|
||||
readonly property string target: path ? "file://" + encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F") : ""
|
||||
// The first wallpaper (and reduced motion) appears directly; later changes
|
||||
// load into `incoming` and are revealed once decoded.
|
||||
onTargetChanged: {
|
||||
if (!shown.source.toString() || Theme.duration === 0) {
|
||||
reveal.stop(); progress = 0; incoming.source = ""; shown.source = target;
|
||||
return;
|
||||
}
|
||||
// Mid-change: land on the wallpaper it was heading to (it is decoded and
|
||||
// cached), then head for the next one from there.
|
||||
if (reveal.running) {
|
||||
reveal.stop();
|
||||
shown.source = incoming.source;
|
||||
}
|
||||
progress = 0;
|
||||
if (target === shown.source.toString()) {
|
||||
incoming.source = "";
|
||||
return;
|
||||
}
|
||||
reported = false;
|
||||
loading();
|
||||
WallpaperService.prepareTransition(path, true);
|
||||
incomingPath = path;
|
||||
incoming.source = target;
|
||||
}
|
||||
Component.onCompleted: shown.source = target
|
||||
function settle() {
|
||||
if (!reveal.running && shown.status === Image.Ready && shown.source.toString() === incoming.source.toString())
|
||||
incoming.source = "";
|
||||
}
|
||||
Image {
|
||||
id: shown
|
||||
anchors.fill: parent
|
||||
sourceSize: Qt.size(root.width, root.height)
|
||||
asynchronous: true
|
||||
retainWhileLoading: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
// Drop the overlay only once the base layer shows the new image.
|
||||
onStatusChanged: root.settle()
|
||||
}
|
||||
// The incoming image and the outline maps are only textures: the shader
|
||||
// draws the change over `shown`.
|
||||
Image {
|
||||
id: incoming
|
||||
visible: false
|
||||
sourceSize: Qt.size(root.width, root.height)
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
onStatusChanged: {
|
||||
if (status === Image.Error)
|
||||
incoming.source = "";
|
||||
else
|
||||
root.reportIfReady();
|
||||
}
|
||||
}
|
||||
// The outline plan for the incoming wallpaper (WallpaperService), once known.
|
||||
property string incomingPath: ""
|
||||
readonly property var plan: root.transitioning ? WallpaperService.transitions[root.incomingPath] : undefined
|
||||
readonly property bool wantsOutline: !!root.plan && root.plan.kind === "outline"
|
||||
readonly property bool outlineReady: root.wantsOutline && fieldMap.status === Image.Ready && lineMap.status === Image.Ready
|
||||
// Settled: colonies, outline maps loaded, or maps that failed (colonies then).
|
||||
readonly property bool planSettled: root.plan !== undefined && (!root.wantsOutline || root.outlineReady
|
||||
|| fieldMap.status === Image.Error || lineMap.status === Image.Error)
|
||||
onPlanSettledChanged: reportIfReady()
|
||||
property bool reported: false
|
||||
function reportIfReady() {
|
||||
if (reported || incoming.status !== Image.Ready || !incoming.source.toString() || !planSettled)
|
||||
return;
|
||||
reported = true;
|
||||
ready();
|
||||
if (!waitForGo)
|
||||
go();
|
||||
}
|
||||
// Starts the change if the new image is decoded. Without a settled plan
|
||||
// (the owner's fallback fired first) it uses colonies.
|
||||
function go() {
|
||||
if (incoming.status !== Image.Ready || !incoming.source.toString() || reveal.running || progress !== 0)
|
||||
return;
|
||||
seed = Math.random() * 100;
|
||||
ember = Theme.accentVivid;
|
||||
mode = outlineReady ? 1 : 0;
|
||||
reveal.duration = mode ? 2000 : 1800;
|
||||
reveal.restart();
|
||||
}
|
||||
// Maps hold numbers, not colours, at their own size; the shader interpolates.
|
||||
Image {
|
||||
id: fieldMap
|
||||
visible: false
|
||||
asynchronous: true
|
||||
cache: false
|
||||
source: root.wantsOutline ? "file://" + root.plan.field : ""
|
||||
}
|
||||
Image {
|
||||
id: lineMap
|
||||
visible: false
|
||||
asynchronous: true
|
||||
cache: false
|
||||
source: root.wantsOutline ? "file://" + root.plan.line : ""
|
||||
}
|
||||
// PreserveAspectCrop decodes to cover the item, so the texture can be
|
||||
// larger than the item on one axis: sample its centred window.
|
||||
function crop(img) {
|
||||
const iw = Math.max(img.implicitWidth, 1), ih = Math.max(img.implicitHeight, 1);
|
||||
const s = Math.max(root.width / iw, root.height / ih);
|
||||
const w = root.width / (iw * s), h = root.height / (ih * s);
|
||||
return Qt.vector4d((1 - w) / 2, (1 - h) / 2, w, h);
|
||||
}
|
||||
ShaderEffect {
|
||||
anchors.fill: parent
|
||||
visible: root.transitioning && incoming.status === Image.Ready && root.progress > 0
|
||||
property var oldTex: shown
|
||||
property var newTex: incoming
|
||||
property real t: root.progress
|
||||
property real sw: width
|
||||
property real sh: height
|
||||
property real cell: 4
|
||||
property real glow: 0.9
|
||||
property real seed: root.seed
|
||||
property vector4d cropOld: root.crop(shown)
|
||||
property vector4d cropNew: root.crop(incoming)
|
||||
property color ember: root.ember
|
||||
property color ink: Theme.text
|
||||
property real mode: root.mode
|
||||
// Unused in colonies mode, but every sampler needs a texture.
|
||||
property var fieldTex: root.outlineReady ? fieldMap : incoming
|
||||
property var lineTex: root.outlineReady ? lineMap : incoming
|
||||
property real fw: Math.max(fieldMap.implicitWidth, 1)
|
||||
property real fh: Math.max(fieldMap.implicitHeight, 1)
|
||||
property real lineW: 1.5
|
||||
property real sdRange: 16
|
||||
fragmentShader: Qt.resolvedUrl("shaders/transition.frag.qsb")
|
||||
}
|
||||
// Captured when a change starts, so the burn keeps its colour even if the
|
||||
// palette regenerates from the new wallpaper halfway through.
|
||||
property real seed: 0
|
||||
property color ember: Theme.accentVivid
|
||||
property real mode: 0
|
||||
NumberAnimation {
|
||||
id: reveal
|
||||
target: root
|
||||
property: "progress"
|
||||
from: 0
|
||||
to: 1
|
||||
// Linear time: the shader eases its own phases. Set per change.
|
||||
easing.type: Easing.Linear
|
||||
onFinished: {
|
||||
shown.source = incoming.source;
|
||||
Qt.callLater(root.settle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import "../services"
|
||||
@@ -16,78 +15,19 @@ PanelWindow {
|
||||
WlrLayershell.layer:WlrLayer.Background
|
||||
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
||||
mask:Region {}
|
||||
readonly property string target:ConfigService.ready && ConfigService.data.wallpaper.byMonitor[root.modelData.name] ? "file://"+encodeURI(ConfigService.data.wallpaper.byMonitor[root.modelData.name]).replace(/#/g,"%23").replace(/\?/g,"%3F") : ""
|
||||
// 0..1 while a new wallpaper grows in from the centre over the old one.
|
||||
property real progress:0
|
||||
readonly property bool transitioning:incoming.source.toString()!==""
|
||||
// The first wallpaper (and reduced motion) appears directly; later changes
|
||||
// load into `incoming` and are revealed once decoded.
|
||||
onTargetChanged:{
|
||||
if(!shown.source.toString() || Theme.duration===0) {reveal.stop();incoming.source="";shown.source=target;}
|
||||
else if(target===shown.source.toString()) {reveal.stop();incoming.source="";}
|
||||
else {reveal.stop();progress=0;WallpaperService.revealLoading(modelData.name);incoming.source=target;}
|
||||
}
|
||||
Component.onCompleted:shown.source=target
|
||||
function settle() {
|
||||
if(!reveal.running && shown.status===Image.Ready && shown.source.toString()===incoming.source.toString())incoming.source="";
|
||||
}
|
||||
Image {
|
||||
id:shown
|
||||
readonly property string targetPath:ConfigService.ready ? (ConfigService.data.wallpaper.byMonitor[root.modelData.name] || "") : ""
|
||||
TransitionStage {
|
||||
id:stage
|
||||
anchors.fill:parent
|
||||
sourceSize:Qt.size(parent.width,parent.height)
|
||||
asynchronous:true
|
||||
retainWhileLoading:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
// Drop the overlay only once the base layer shows the new image.
|
||||
onStatusChanged:root.settle()
|
||||
}
|
||||
Item {
|
||||
id:revealMask
|
||||
anchors.fill:parent
|
||||
visible:false
|
||||
layer.enabled:root.transitioning
|
||||
Rectangle {
|
||||
readonly property real reach:Math.hypot(root.width,root.height)*1.15
|
||||
anchors.centerIn:parent
|
||||
width:reach*root.progress;height:width;radius:width/2
|
||||
color:"black"
|
||||
}
|
||||
}
|
||||
// The mask must be the image's own layer effect: a MultiEffect pointed at a
|
||||
// hidden source renders nothing here.
|
||||
Image {
|
||||
id:incoming
|
||||
anchors.fill:parent
|
||||
visible:root.transitioning && root.progress>0
|
||||
sourceSize:Qt.size(parent.width,parent.height)
|
||||
asynchronous:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
// Settles from a slight zoom while the circle widens, like swww/awww "grow".
|
||||
scale:1.06-0.06*root.progress
|
||||
onStatusChanged:{
|
||||
if(status===Image.Ready && source.toString())WallpaperService.revealReady(root.modelData.name);
|
||||
else if(status===Image.Error)incoming.source="";
|
||||
}
|
||||
layer.enabled:root.transitioning
|
||||
layer.effect:MultiEffect {
|
||||
maskEnabled:true
|
||||
maskSource:revealMask
|
||||
maskThresholdMin:0.5
|
||||
maskSpreadAtMin:1
|
||||
}
|
||||
// Every output starts its change together (WallpaperService.revealSerial).
|
||||
waitForGo:true
|
||||
onLoading:WallpaperService.revealLoading(root.modelData.name)
|
||||
onReady:WallpaperService.revealReady(root.modelData.name)
|
||||
}
|
||||
onTargetPathChanged:stage.path=targetPath
|
||||
Component.onCompleted:stage.path=targetPath
|
||||
Connections {
|
||||
target:WallpaperService
|
||||
function onRevealSerialChanged() {
|
||||
if(incoming.status===Image.Ready && incoming.source.toString() && !reveal.running && root.progress===0)reveal.restart();
|
||||
}
|
||||
}
|
||||
NumberAnimation {
|
||||
id:reveal
|
||||
target:root;property:"progress"
|
||||
from:0;to:1
|
||||
duration:1100
|
||||
easing.type:Easing.InOutCubic
|
||||
onFinished:{shown.source=incoming.source;Qt.callLater(root.settle);}
|
||||
function onRevealSerialChanged() {stage.go();}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
@@ -29,22 +30,74 @@ PanelWindow {
|
||||
Component.onDestruction:ShellState.wallpaperWindow=null
|
||||
property string filter:"all"
|
||||
readonly property var results:WallpaperService.images.filter(i=>(filter!=="history" || ConfigService.data.wallpaper.history.includes(i.path)) && (!search.text || i.name.toLowerCase().includes(search.text.toLowerCase())))
|
||||
// A vertical mouse wheel steps through the horizontal strip, one tile per notch.
|
||||
// Handled on the tiles: their MouseAreas take wheel events before the ListView.
|
||||
property real wheelPending:0
|
||||
function wheelStep(event) {
|
||||
wheelPending+=event.angleDelta.y || event.angleDelta.x;
|
||||
const steps=Math.trunc(wheelPending/120);
|
||||
if(!steps)return;
|
||||
wheelPending-=steps*120;
|
||||
view.currentIndex=Math.max(0,Math.min(view.count-1,view.currentIndex-steps));
|
||||
|
||||
// Justified rows, as in a photo gallery: every thumbnail keeps its own
|
||||
// aspect ratio (from the scan's header sizes) and each row is scaled so it
|
||||
// fills the width exactly. The last row keeps the target height.
|
||||
readonly property real rowTarget:170
|
||||
readonly property real gap:10
|
||||
readonly property var rows:layoutRows(results,view.width)
|
||||
function aspectOf(image) {
|
||||
const a=image.width>0 && image.height>0 ? image.width/image.height : 16/9;
|
||||
return Math.max(0.5,Math.min(3,a)); // keep panoramas and slivers usable
|
||||
}
|
||||
function layoutRows(images,width) {
|
||||
const out=[];
|
||||
if(width<=0)return out;
|
||||
let row=[],sum=0;
|
||||
const close=height=>{
|
||||
let x=0;
|
||||
out.push({height:height,tiles:row.map(t=>{const w=t.aspect*height;const tile={index:t.index,x:x,width:w};x+=w+root.gap;return tile;})});
|
||||
row=[];sum=0;
|
||||
};
|
||||
images.forEach((image,index)=>{
|
||||
const aspect=aspectOf(image);
|
||||
row.push({index:index,aspect:aspect});sum+=aspect;
|
||||
if(sum*rowTarget+gap*(row.length-1)>=width)close((width-gap*(row.length-1))/sum);
|
||||
});
|
||||
if(row.length)close(rowTarget);
|
||||
return out;
|
||||
}
|
||||
// Where each result sits: its row, and its horizontal centre for up/down.
|
||||
readonly property var places:{
|
||||
const p=[];
|
||||
rows.forEach((row,r)=>row.tiles.forEach(t=>p[t.index]={row:r,center:t.x+t.width/2}));
|
||||
return p;
|
||||
}
|
||||
|
||||
property int current:0
|
||||
onResultsChanged:if(current>=results.length)current=Math.max(0,results.length-1)
|
||||
function select(index) {
|
||||
if(index<0 || index>=results.length)return;
|
||||
current=index;
|
||||
if(places[index])view.positionViewAtIndex(places[index].row,ListView.Contain);
|
||||
}
|
||||
// Up/down: the tile in the next row whose centre is closest.
|
||||
function vertical(direction) {
|
||||
const here=places[current];
|
||||
if(!here)return select(0);
|
||||
const row=rows[here.row+direction];
|
||||
if(!row)return;
|
||||
let best=row.tiles[0];
|
||||
for(const t of row.tiles)if(Math.abs(t.x+t.width/2-here.center)<Math.abs(best.x+best.width/2-here.center))best=t;
|
||||
select(best.index);
|
||||
}
|
||||
function applyCurrent() {if(root.results[current])WallpaperService.apply(root.results[current].path);}
|
||||
// For the test driver: the thumbnail item of a result, scrolled into view.
|
||||
function tileAt(index) {
|
||||
const place=places[index];
|
||||
if(!place)return null;
|
||||
view.positionViewAtIndex(place.row,ListView.Contain);
|
||||
const row=view.itemAtIndex(place.row);
|
||||
return row ? row.tileAt(index) : null;
|
||||
}
|
||||
function applyCurrent() {if(root.results[view.currentIndex])WallpaperService.apply(root.results[view.currentIndex].path);}
|
||||
Connections {
|
||||
target:ShellState
|
||||
function onWallpaperPickerOpenChanged() {
|
||||
if(ShellState.wallpaperPickerOpen) {
|
||||
WallpaperService.refresh();WallpaperService.scan();
|
||||
const at=root.results.findIndex(i=>i.path===WallpaperService.currentPath);
|
||||
if(at>=0)root.select(at);
|
||||
Qt.callLater(()=>view.forceActiveFocus());
|
||||
}
|
||||
}
|
||||
@@ -57,13 +110,13 @@ PanelWindow {
|
||||
y:BarDrawers.bottom
|
||||
open:ShellState.wallpaperPickerOpen
|
||||
contentWidth:Math.min(1240,root.screenWidth-2*(BarDrawers.margin+BarDrawers.radius+ear))
|
||||
contentHeight:Math.min(590,root.screenHeight-BarDrawers.bottom-40)
|
||||
contentHeight:Math.min(640,root.screenHeight-BarDrawers.bottom-40)
|
||||
drawerId:"wallpaper"
|
||||
screenName:root.screen ? root.screen.name : ""
|
||||
screenX:(root.screenWidth-width)/2
|
||||
MouseArea {anchors.fill:parent}
|
||||
ColumnLayout {
|
||||
anchors.fill:parent;anchors.margins:22;spacing:18
|
||||
anchors.fill:parent;anchors.margins:22;spacing:16
|
||||
RowLayout {
|
||||
Layout.fillWidth:true
|
||||
Text {text:"Wallpapers";color:Theme.text;font.pixelSize:24;Layout.fillWidth:true}
|
||||
@@ -79,45 +132,111 @@ PanelWindow {
|
||||
RowLayout {
|
||||
GlassButton {text:"All";accented:root.filter==="all";onClicked:root.filter="all"}
|
||||
GlassButton {text:"History";accented:root.filter==="history";onClicked:root.filter="history"}
|
||||
GlassTextField {id:search;objectName:"wallpaperSearch";Layout.fillWidth:true;placeholderText:"Search wallpapers…";onTextChanged:view.currentIndex=0;Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false;Keys.onDownPressed:view.forceActiveFocus()}
|
||||
GlassTextField {id:search;objectName:"wallpaperSearch";Layout.fillWidth:true;placeholderText:"Search wallpapers…";onTextChanged:root.select(0);Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false;Keys.onDownPressed:view.forceActiveFocus()}
|
||||
GlassIconButton {text:"↻";onClicked:WallpaperService.scan();Accessible.name:"Refresh wallpapers"}
|
||||
}
|
||||
ListView {
|
||||
id:view
|
||||
objectName:"wallpaperCarousel"
|
||||
objectName:"wallpaperGallery"
|
||||
Layout.fillWidth:true;Layout.fillHeight:true
|
||||
orientation:ListView.Horizontal
|
||||
spacing:14
|
||||
spacing:root.gap
|
||||
clip:true
|
||||
model:root.results
|
||||
snapMode:ListView.SnapToItem
|
||||
model:root.rows
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
highlightMoveDuration:Theme.duration
|
||||
preferredHighlightBegin:width/2-125
|
||||
preferredHighlightEnd:width/2+125
|
||||
highlightRangeMode:ListView.ApplyRange
|
||||
keyNavigationEnabled:true
|
||||
ScrollBar.horizontal:ScrollBar {}
|
||||
ScrollBar.vertical:ScrollBar {}
|
||||
Keys.onLeftPressed:root.select(root.current-1)
|
||||
Keys.onRightPressed:root.select(root.current+1)
|
||||
Keys.onUpPressed:root.vertical(-1)
|
||||
Keys.onDownPressed:root.vertical(1)
|
||||
Keys.onReturnPressed:root.applyCurrent()
|
||||
Keys.onEnterPressed:root.applyCurrent()
|
||||
Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false
|
||||
delegate:GlassPanel {
|
||||
id:tile
|
||||
delegate:Item {
|
||||
id:rowItem
|
||||
required property var modelData
|
||||
required property int index
|
||||
width:250;height:view.height-10
|
||||
radius:18
|
||||
border.width:2
|
||||
border.color:view.currentIndex===index ? Theme.accent : Theme.border
|
||||
Image {anchors.fill:parent;anchors.margins:6;source:tile.modelData.url;sourceSize:Qt.size(500,700);asynchronous:true;fillMode:Image.PreserveAspectCrop;clip:true}
|
||||
Rectangle {anchors.bottom:parent.bottom;anchors.left:parent.left;anchors.right:parent.right;anchors.margins:6;height:42;color:Qt.alpha(Theme.surface,0.85)
|
||||
Text {anchors.fill:parent;anchors.margins:10;text:(WallpaperService.currentPath===tile.modelData.path?"✓ ":"")+tile.modelData.name;color:Theme.text;elide:Text.ElideMiddle}
|
||||
width:view.width
|
||||
height:modelData.height
|
||||
function tileAt(index) {
|
||||
for(let i=0;i<tiles.count;i++)if(tiles.itemAt(i).modelData.index===index)return tiles.itemAt(i);
|
||||
return null;
|
||||
}
|
||||
Repeater {
|
||||
id:tiles
|
||||
model:rowItem.modelData.tiles
|
||||
delegate:Item {
|
||||
id:tile
|
||||
required property var modelData
|
||||
readonly property var image:root.results[modelData.index]
|
||||
readonly property bool selected:root.current===modelData.index
|
||||
x:modelData.x;width:modelData.width;height:rowItem.height
|
||||
Item {
|
||||
anchors.fill:parent
|
||||
scale:hover.containsMouse && !tile.selected ? 1.02 : 1
|
||||
Behavior on scale {NumberAnimation {duration:Theme.duration;easing.type:Easing.OutCubic}}
|
||||
Image {
|
||||
anchors.fill:parent
|
||||
source:tile.image ? tile.image.url : ""
|
||||
sourceSize:Qt.size(Math.round(tile.width*1.5),Math.round(tile.height*1.5))
|
||||
asynchronous:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
opacity:status===Image.Ready ? 1 : 0
|
||||
Behavior on opacity {NumberAnimation {duration:Theme.duration}}
|
||||
layer.enabled:true
|
||||
layer.effect:MultiEffect {maskEnabled:true;maskSource:mask;maskThresholdMin:0.5;maskSpreadAtMin:1}
|
||||
}
|
||||
Item {
|
||||
id:mask
|
||||
anchors.fill:parent
|
||||
visible:false
|
||||
layer.enabled:true
|
||||
Rectangle {anchors.fill:parent;radius:12}
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill:parent;radius:12;color:"transparent"
|
||||
border.width:tile.selected ? 3 : 1
|
||||
border.color:tile.selected ? Theme.accent : Theme.border
|
||||
}
|
||||
// Name on the selected or hovered thumbnail only.
|
||||
Rectangle {
|
||||
anchors.left:parent.left;anchors.right:parent.right;anchors.bottom:parent.bottom;anchors.margins:3
|
||||
height:30;radius:9
|
||||
color:Qt.alpha(Theme.surface,0.78)
|
||||
opacity:tile.selected || hover.containsMouse ? 1 : 0
|
||||
Behavior on opacity {NumberAnimation {duration:Theme.duration}}
|
||||
Text {
|
||||
anchors.fill:parent;anchors.leftMargin:10;anchors.rightMargin:10
|
||||
verticalAlignment:Text.AlignVCenter
|
||||
text:tile.image ? tile.image.name : ""
|
||||
color:Theme.text;font.pixelSize:12;elide:Text.ElideMiddle
|
||||
}
|
||||
}
|
||||
// ✦ the subject's outline is drawn first · ✓ current wallpaper
|
||||
Row {
|
||||
anchors.top:parent.top;anchors.right:parent.right;anchors.margins:7;spacing:5
|
||||
Repeater {
|
||||
model:tile.image ? [WallpaperService.outlineStatus[tile.image.path]==="outline" ? "✦" : "",
|
||||
tile.image.path===WallpaperService.currentPath ? "✓" : ""].filter(s=>s) : []
|
||||
delegate:Rectangle {
|
||||
required property string modelData
|
||||
width:22;height:22;radius:11
|
||||
color:Qt.alpha("black",0.55)
|
||||
Text {anchors.centerIn:parent;text:parent.modelData;color:"white";font.pixelSize:12}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id:hover
|
||||
anchors.fill:parent
|
||||
hoverEnabled:true
|
||||
onClicked:{root.current=tile.modelData.index;view.forceActiveFocus();root.applyCurrent();}
|
||||
}
|
||||
}
|
||||
}
|
||||
MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}onWheel:event=>root.wheelStep(event)}
|
||||
}
|
||||
}
|
||||
Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"Click or ← → and Enter to apply · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"Click or arrows and Enter to apply · ✦ outline transition · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
#version 440
|
||||
// Wallpaper change, two kinds, both in crisp pixel cells:
|
||||
//
|
||||
// COLONIES (mode 0), any wallpaper: colonies of the new wallpaper land at a
|
||||
// few places and moments and eat through the old one along noise-warped
|
||||
// fronts. Each flipped cell burns for an instant in the accent colour, a thin
|
||||
// glow rides the front, and now and then a spark jumps ahead. Procedural:
|
||||
// `seed` makes every change differ.
|
||||
//
|
||||
// OUTLINE (mode 1), a wallpaper with a clear subject: the old wallpaper steps
|
||||
// back, a thin line draws the subject's outline (two pens from its top), the
|
||||
// subject fills in from that outline, and the rest of the picture grows out
|
||||
// of it. The maps come from helpers/wallfx.py, in the new image's space.
|
||||
//
|
||||
// Extra effects vanish at both ends, so t=0 is exactly the old wallpaper and
|
||||
// t=1 exactly the new one.
|
||||
// Rebuild transition.frag.qsb with scripts/build-shaders after editing.
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
layout(std140, binding = 0) uniform buf {
|
||||
mat4 qt_Matrix;
|
||||
float qt_Opacity;
|
||||
float t; // 0..1, linear in time
|
||||
float mode; // 0 colonies, 1 outline
|
||||
float sw; // item size, px
|
||||
float sh;
|
||||
float cell; // cell size, px
|
||||
float glow; // 0..1, strength of the burn and the front glow
|
||||
float seed;
|
||||
float fw; // fieldTex / lineTex size, texels (outline only)
|
||||
float fh;
|
||||
float lineW; // outline width, px
|
||||
float sdRange; // fieldTex G spans +-sdRange map px
|
||||
vec4 cropOld; // texture uv = xy + item uv * zw (PreserveAspectCrop)
|
||||
vec4 cropNew;
|
||||
vec4 ember; // accent: the colonies' burning edge
|
||||
vec4 ink; // light tone: the outline's line
|
||||
};
|
||||
layout(binding = 1) uniform sampler2D oldTex;
|
||||
layout(binding = 2) uniform sampler2D newTex;
|
||||
layout(binding = 3) uniform sampler2D fieldTex;
|
||||
layout(binding = 4) uniform sampler2D lineTex;
|
||||
|
||||
const float PI = 3.14159265;
|
||||
const int COLS = 3; // seeds are stratified on a COLS x ROWS grid, so
|
||||
const int ROWS = 2; // no part of the screen is far from every colony
|
||||
const float START = 0.22; // latest moment a colony may land
|
||||
const float WARP = 0.22; // how far the noise bends the fronts, screen heights
|
||||
const float GRAIN = 0.035; // per-cell jitter: ragged, crisp edges
|
||||
const float LIFE = 0.06; // how long a flipped cell burns
|
||||
|
||||
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7)) + seed * 13.17) * 43758.5453); }
|
||||
float hash1(float n) { return fract(sin(n * 91.345 + seed * 7.91) * 47453.5453); }
|
||||
float escena(float x) { x = clamp(x, 0.0, 1.0); return x * x * (3.0 - 2.0 * x); }
|
||||
|
||||
float vnoise(vec2 p) {
|
||||
vec2 i = floor(p), f = p - i;
|
||||
f = f * f * (3.0 - 2.0 * f);
|
||||
return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
|
||||
mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x), f.y);
|
||||
}
|
||||
float fbm(vec2 p) {
|
||||
return 0.52 * vnoise(p) + 0.30 * vnoise(p * 2.7 + 17.0) + 0.18 * vnoise(p * 7.3 + 41.0);
|
||||
}
|
||||
|
||||
// Latest arrival, measured over many seeds and aspect ratios (16:9, 21:9, 1:1,
|
||||
// 9:16): the worst case stays under half the latest landing plus one zone
|
||||
// diagonal. Any straggler past it is closed at t=1.
|
||||
float aspect() { return sw / sh; }
|
||||
float maxArrival() {
|
||||
vec2 zone = vec2(aspect() / float(COLS), 1.0 / float(ROWS));
|
||||
return START * 0.5 + length(zone) + 0.04;
|
||||
}
|
||||
|
||||
// Arrival (as a fraction of maxArrival) at which a given fraction of the
|
||||
// screen is covered, from the same measurements: mapping time through it
|
||||
// makes the covered AREA grow evenly instead of crawling, then rushing.
|
||||
float areaToArrival(float f) {
|
||||
if (f < 0.10) return mix(0.00, 0.22, f / 0.10);
|
||||
if (f < 0.25) return mix(0.22, 0.29, (f - 0.10) / 0.15);
|
||||
if (f < 0.50) return mix(0.29, 0.37, (f - 0.25) / 0.25);
|
||||
if (f < 0.75) return mix(0.37, 0.46, (f - 0.50) / 0.25);
|
||||
if (f < 0.90) return mix(0.46, 0.54, (f - 0.75) / 0.15);
|
||||
return mix(0.54, 1.00, (f - 0.90) / 0.10);
|
||||
}
|
||||
|
||||
// When the cell at `c` (cell coordinates) flips, in the same units as maxArrival().
|
||||
float arrivalAt(vec2 c) {
|
||||
vec2 q = (c + 0.5) * cell / sh; // screen-height units
|
||||
vec2 w = vec2(fbm(q * 3.1 + seed), fbm(q * 3.1 + seed + 23.7)) - 0.5;
|
||||
q += w * WARP;
|
||||
float a = 1e6;
|
||||
for (int y = 0; y < ROWS; y++) {
|
||||
for (int x = 0; x < COLS; x++) {
|
||||
float n = float(y * COLS + x);
|
||||
vec2 zone = vec2(aspect() / float(COLS), 1.0 / float(ROWS));
|
||||
vec2 s = (vec2(float(x), float(y)) + 0.2 + 0.6 * vec2(hash1(n), hash1(n + 31.0))) * zone;
|
||||
float t0 = START * hash1(n + 57.0);
|
||||
float speed = 0.85 + 0.3 * hash1(n + 83.0); // some colonies are hungrier
|
||||
a = min(a, t0 + length(q - s) / speed);
|
||||
}
|
||||
}
|
||||
return a + GRAIN * hash(c + 0.37);
|
||||
}
|
||||
|
||||
vec3 oldAt(vec2 uv) { return texture(oldTex, cropOld.xy + uv * cropOld.zw).rgb; }
|
||||
vec2 newUv(vec2 uv, float zoom) { return cropNew.xy + (0.5 + (uv - 0.5) / zoom) * cropNew.zw; }
|
||||
vec3 newAt(vec2 uv, float zoom) { return texture(newTex, newUv(uv, zoom)).rgb; }
|
||||
float luma(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
|
||||
|
||||
vec3 colonies(vec2 uv) {
|
||||
float energy = sin(PI * t);
|
||||
float span = maxArrival();
|
||||
float T = areaToArrival(escena(t)) * (span + LIFE + 0.01) - 0.01;
|
||||
vec2 cellPos = floor(uv * vec2(sw, sh) / cell);
|
||||
float a = arrivalAt(cellPos);
|
||||
float flick = hash(cellPos + 0.71);
|
||||
vec3 hot = mix(ember.rgb, vec3(1.0), 0.18);
|
||||
vec3 c;
|
||||
if (a > T) {
|
||||
c = oldAt(uv);
|
||||
float ahead = a - T; // a spark just ahead of the front
|
||||
if (flick > 0.985 && ahead < 0.03)
|
||||
c = mix(c, hot, (1.0 - ahead / 0.03) * 0.8 * glow * step(0.0, T));
|
||||
} else {
|
||||
c = newAt(uv, 1.0 + 0.025 * (1.0 - escena(t))); // settles from a touch closer
|
||||
bool edge = max(max(arrivalAt(cellPos + vec2(1.0, 0.0)), arrivalAt(cellPos - vec2(1.0, 0.0))),
|
||||
max(arrivalAt(cellPos + vec2(0.0, 1.0)), arrivalAt(cellPos - vec2(0.0, 1.0)))) > T;
|
||||
float life = clamp((T - a) / LIFE, 0.0, 1.0);
|
||||
float burn = (1.0 - life) * (1.0 - life) * (edge ? 1.0 : 0.55);
|
||||
c = mix(c, hot, burn * (0.55 + 0.45 * flick) * 0.85 * glow);
|
||||
}
|
||||
return c + ember.rgb * 0.22 * glow * energy * exp(-abs(a - T) / 0.012);
|
||||
}
|
||||
|
||||
// 16-bit order in lineTex G (high) and B (low), interpolated by hand: the
|
||||
// sampler's bilinear filter would blend the two bytes separately.
|
||||
float order16(vec2 texel) {
|
||||
texel = clamp(texel, vec2(0.0), vec2(fw, fh) - 1.0);
|
||||
vec4 f = texture(lineTex, (texel + 0.5) / vec2(fw, fh));
|
||||
return (floor(f.g * 255.0 + 0.5) * 256.0 + floor(f.b * 255.0 + 0.5)) / 65535.0;
|
||||
}
|
||||
float orderAt(vec2 tuv) {
|
||||
vec2 p = tuv * vec2(fw, fh) - 0.5;
|
||||
vec2 i = floor(p), f = p - i;
|
||||
return mix(mix(order16(i), order16(i + vec2(1.0, 0.0)), f.x),
|
||||
mix(order16(i + vec2(0.0, 1.0)), order16(i + vec2(1.0, 1.0)), f.x), f.y);
|
||||
}
|
||||
|
||||
vec3 outline(vec2 uv) {
|
||||
// The subject settles from a touch closer than its background: a little depth.
|
||||
float zIn = 1.0 + 0.03 * (1.0 - escena(t));
|
||||
float zOut = 1.0 + 0.015 * (1.0 - escena(t));
|
||||
vec4 f = texture(fieldTex, newUv(uv, zIn));
|
||||
float sdPx = (f.g * 2.0 - 1.0) * sdRange * sw * zIn / (fw * cropNew.z); // screen px, > 0 outside
|
||||
float aa = max(fwidth(sdPx), 1e-3);
|
||||
float inside = clamp(0.5 - sdPx / aa, 0.0, 1.0);
|
||||
|
||||
// The old wallpaper steps back: a fifth darker, a quarter greyer.
|
||||
float back = escena(t / 0.18) * (1.0 - escena((t - 0.85) / 0.15));
|
||||
vec3 st = oldAt(uv);
|
||||
st = mix(st, vec3(luma(st)), 0.25 * back) * (1.0 - 0.2 * back);
|
||||
|
||||
// Fronts decide per cell centre, so they are crisp and stepped; the
|
||||
// silhouette itself stays smooth.
|
||||
vec2 grid = vec2(sw, sh) / cell;
|
||||
vec2 cuv = (floor(uv * grid) + 0.5) / grid;
|
||||
float Ti = escena((t - 0.32) / 0.32) * 1.02 - 0.01; // fill, once the line is nearly drawn
|
||||
vec3 cIn = texture(fieldTex, newUv(cuv, zIn)).r <= Ti ? newAt(uv, zIn) : st;
|
||||
float To = escena((t - 0.45) / 0.50) * 1.02 - 0.01; // then the world grows out of it
|
||||
vec3 cOut = orderAt(newUv(cuv, zOut)) <= To ? newAt(uv, zOut) : st;
|
||||
vec3 c = mix(cOut, cIn, inside);
|
||||
|
||||
// The line: thin and quiet, drawn by two pens from the top of every
|
||||
// contour, gone once the subject is in.
|
||||
float drawn = escena((t - 0.02) / 0.33);
|
||||
float lp = texture(lineTex, newUv(uv, zIn)).r;
|
||||
float fade = 1.0 - escena((t - 0.45) / 0.25);
|
||||
if (lp > 0.0 && lp <= drawn && fade > 0.0) {
|
||||
float core = clamp(0.5 - (abs(sdPx) - lineW * 0.5) / aa, 0.0, 1.0);
|
||||
c = mix(c, ink.rgb, core * 0.75 * fade);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = qt_TexCoord0;
|
||||
vec3 c = t >= 1.0 ? newAt(uv, 1.0) : (mode < 0.5 ? colonies(uv) : outline(uv));
|
||||
fragColor = vec4(clamp(c, 0.0, 1.0), 1.0) * qt_Opacity;
|
||||
}
|
||||
Binary file not shown.
@@ -4,6 +4,6 @@
|
||||
# nix shell nixpkgs#qt6.qtshadertools -c ./scripts/build-shaders
|
||||
set -eu
|
||||
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
for source in "$project_dir"/quickshell/lock/shaders/*.frag; do
|
||||
for source in "$project_dir"/quickshell/lock/shaders/*.frag "$project_dir"/quickshell/wallpaper/shaders/*.frag; do
|
||||
qsb --glsl "100 es,120,150" --hlsl 50 --msl 12 -o "$source.qsb" "$source"
|
||||
done
|
||||
Reference in new issue
Block a user