diff --git a/scripts/kanshi-autoconfig b/scripts/kanshi-autoconfig index bdfa08a..e45a1df 100755 --- a/scripts/kanshi-autoconfig +++ b/scripts/kanshi-autoconfig @@ -422,6 +422,42 @@ def notify_send(summary, body=""): pass +def bing_opted_in(): + """Bing-Timer per User aktiviert? (Symlink-Check statt systemctl: + kein D-Bus noetig, funktioniert in jedem Kontext.)""" + return (Path.home() / ".config" / "systemd" / "user" + / "timers.target.wants" / "bing-wallpaper.timer").exists() + + +def maybe_refresh_bing_wallpaper(): + """Bing-Wallpaper nach Output-Wechsel neu auf alle Monitore setzen. + Hintergrund: Neu erscheinende Outputs bekommen sonst Noctalias + Verzeichnis-Default (z.B. curvy-d.jxl) statt Bing. Nur bei aktivem + Opt-in (Timer enabled) - sonst bleibt eine per Picker gewaehlte + Tapete unangetastet. Best-effort: Fehler nur loggen.""" + from datetime import date + if not bing_opted_in(): + return + pics = Path.home() / "Bilder" + if not pics.is_dir(): + pics = Path.home() / "Pictures" + target = pics / "Bing" / f"bing-{date.today().isoformat()}.jpg" + if not target.is_file(): + return + try: + r = subprocess.run( + ["noctalia", "msg", "wallpaper-set", str(target)], + timeout=30, check=False, capture_output=True, text=True, + ) + if r.returncode == 0: + print(f"Bing-Wallpaper erneuert: {target}", flush=True) + else: + print(f"WARN: wallpaper-set fehlgeschlagen: {r.stderr.strip()[:200]}", + file=sys.stderr, flush=True) + except Exception as e: # noqa: BLE001 - optionaler Schritt + print(f"WARN: wallpaper-set nicht moeglich: {e}", file=sys.stderr, flush=True) + + def is_internal_name(name): return name.startswith(("eDP-", "LVDS-", "DSI-")) @@ -534,6 +570,7 @@ def run_watch(): apply(merge_configs(safe_read(CONFIG_PATH), render(outputs))) child = restart_kanshi(child) profile = matching_profile_name(names) + maybe_refresh_bing_wallpaper() notify_send("Monitorprofil gewechselt", f"{profile or 'unbekannt'}: {', '.join(sorted(names))}") last_set = names