Replace aether with a homegrown theme system + desktop theme widget

aether (the third-party GUI app) is gone - it didn't work reliably. Replaced
with theme/: colors.toml (palette), templates/<app>/ (Hyprland, Kitty, Rofi,
mako; unused Waybar template dropped), render.py (renders + reloads apps,
supports --set/--get/--dump), and wallpaper.py (archives + swaps the
wallpaper, deduped by hash, via a native zenity picker).

New ThemeWidget.qml: a small standalone widget pinned to the top-left corner
of the main monitor, independent of the bar and sitting on the Bottom wlr
layer (so normal windows can cover it). Two buttons - wallpaper gallery/picker,
and a color-role picker with a preset palette + hex input - call straight into
the scripts above.

Also includes an unrelated hyprland.lua fix found while testing the widget:
new kitty windows were coming up in genuine Hyprland fullscreen regardless of
workspace; a fullscreen_state window rule forces it off (plain
'fullscreen = false' turned out to be a no-op).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
nico
2026-09-28 01:53:04 +02:00
parent f79449e69d
commit 3c69367660
61 changed files with 875 additions and 1163 deletions

129
theme/wallpaper.py Executable file
View File

@@ -0,0 +1,129 @@
#!/usr/bin/env python3
"""Manages the desktop wallpaper (~/.config/hypr/wallpaper.png, loaded by swaybg).
wallpaper.py list JSON array of previously used wallpapers (newest first),
each {id, path, added, current}; "path" is directly usable
as a QML Image source
wallpaper.py apply <path> archive the current wallpaper, make <path> the new one
wallpaper.py pick open a native file picker, then apply the chosen file
wallpaper.py remove <id> delete one archived wallpaper (refuses the current one)
The picker button in the ThemeWidget calls "list" to fill its gallery of recommendations,
"pick" for "choose a new file", and "apply" again when a gallery entry is clicked.
"""
import hashlib
import json
import os
import shutil
import subprocess
import sys
import time
ACTIVE = os.path.expanduser("~/.config/hypr/wallpaper.png")
ARCHIVE = os.path.expanduser("~/.local/share/quickshell/wallpapers")
MANIFEST = os.path.join(ARCHIVE, "manifest.json")
def load_manifest():
try:
return json.load(open(MANIFEST))
except (OSError, json.JSONDecodeError):
return []
def save_manifest(entries):
os.makedirs(ARCHIVE, exist_ok=True)
json.dump(entries, open(MANIFEST, "w"), indent=1)
def sha256(path):
h = hashlib.sha256()
with open(path, "rb") as f:
for chunk in iter(lambda: f.read(1 << 20), b""):
h.update(chunk)
return h.hexdigest()
def archive_current(entries):
"""Copies the currently active wallpaper into the archive, if it isn't there already."""
if not os.path.isfile(ACTIVE):
return
digest = sha256(ACTIVE)
if any(e["sha256"] == digest for e in entries):
return
os.makedirs(ARCHIVE, exist_ok=True)
next_id = max([e["id"] for e in entries], default=0) + 1
ext = os.path.splitext(ACTIVE)[1] or ".png"
dest = os.path.join(ARCHIVE, f"{next_id:04d}{ext}")
shutil.copy2(ACTIVE, dest)
entries.append({"id": next_id, "file": os.path.basename(dest), "sha256": digest,
"added": time.strftime("%Y-%m-%d %H:%M")})
def restart_swaybg():
subprocess.run(["pkill", "-x", "swaybg"], check=False, capture_output=True)
subprocess.Popen(["swaybg", "-i", ACTIVE, "-m", "fill"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
start_new_session=True)
def cmd_list():
entries = load_manifest()
current = sha256(ACTIVE) if os.path.isfile(ACTIVE) else None
out = [{"id": e["id"], "path": os.path.join(ARCHIVE, e["file"]), "added": e["added"],
"current": e["sha256"] == current} for e in entries]
out.sort(key=lambda e: -e["id"])
print(json.dumps(out))
def cmd_apply(path):
path = os.path.expanduser(path)
if not os.path.isfile(path):
sys.exit(f"wallpaper.py: no such file: {path}")
entries = load_manifest()
archive_current(entries)
shutil.copy2(path, ACTIVE)
save_manifest(entries)
restart_swaybg()
def cmd_pick():
result = subprocess.run(
["zenity", "--file-selection", "--title=Wallpaper wählen",
"--file-filter=Images | *.png *.jpg *.jpeg *.webp *.bmp"],
capture_output=True, text=True)
path = result.stdout.strip()
if result.returncode != 0 or not path:
return # cancelled
cmd_apply(path)
def cmd_remove(id_str):
wanted = int(id_str)
entries = load_manifest()
current = sha256(ACTIVE) if os.path.isfile(ACTIVE) else None
match = next((e for e in entries if e["id"] == wanted), None)
if match is None:
sys.exit(f"wallpaper.py: no archived wallpaper with id {wanted}")
if match["sha256"] == current:
sys.exit("wallpaper.py: refusing to remove the currently active wallpaper")
os.remove(os.path.join(ARCHIVE, match["file"]))
save_manifest([e for e in entries if e["id"] != wanted])
def main():
args = sys.argv[1:]
if args[:1] == ["list"]:
cmd_list()
elif args[:1] == ["apply"] and len(args) == 2:
cmd_apply(args[1])
elif args[:1] == ["pick"]:
cmd_pick()
elif args[:1] == ["remove"] and len(args) == 2:
cmd_remove(args[1])
else:
sys.exit(__doc__)
if __name__ == "__main__":
main()