feat: automatically sync KDE KScreenLocker lockscreen wallpaper with current desktop wallpaper

This commit is contained in:
Sho 2026-08-02 14:09:48 +09:00
parent b56a9fa115
commit bb6baa5f5e
3 changed files with 10 additions and 0 deletions

View File

@ -38,6 +38,7 @@ Item {
Theme.wallpaperPath = fileUrl Theme.wallpaperPath = fileUrl
let rawPath = parsed.wallpaper.replace("file://", "") let rawPath = parsed.wallpaper.replace("file://", "")
Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath]) Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath])
Quickshell.execDetached(["kwriteconfig6", "--file", "kscreenlockerrc", "--group", "Greeter", "--group", "Wallpaper", "--group", "org.kde.image", "--group", "General", "--key", "Image", "file://" + rawPath])
} }
} }
} catch (e) {} } catch (e) {}
@ -91,6 +92,7 @@ Item {
} }
Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath]) Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath])
Quickshell.execDetached(["kwriteconfig6", "--file", "kscreenlockerrc", "--group", "Greeter", "--group", "Wallpaper", "--group", "org.kde.image", "--group", "General", "--key", "Image", "file://" + rawPath])
if (!skipSave) { if (!skipSave) {
Quickshell.execDetached(["python3", Quickshell.env("HOME") + "/.config/quickshell/services/python/save_wallpaper.py", rawPath, vName]) Quickshell.execDetached(["python3", Quickshell.env("HOME") + "/.config/quickshell/services/python/save_wallpaper.py", rawPath, vName])

View File

@ -36,5 +36,12 @@ def save_wallpaper():
except Exception: except Exception:
pass pass
try:
import subprocess
file_url = wp_path if wp_path.startswith("file://") else f"file://{wp_path}"
subprocess.run(["kwriteconfig6", "--file", "kscreenlockerrc", "--group", "Greeter", "--group", "Wallpaper", "--group", "org.kde.image", "--group", "General", "--key", "Image", file_url], capture_output=True)
except Exception:
pass
if __name__ == '__main__': if __name__ == '__main__':
save_wallpaper() save_wallpaper()

View File

@ -182,6 +182,7 @@ Item {
wallpaperPath = imgPath.startsWith("file://") ? imgPath : "file://" + imgPath wallpaperPath = imgPath.startsWith("file://") ? imgPath : "file://" + imgPath
let rawPath = imgPath.replace("file://", "") let rawPath = imgPath.replace("file://", "")
Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath]) Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath])
Quickshell.execDetached(["kwriteconfig6", "--file", "kscreenlockerrc", "--group", "Greeter", "--group", "Wallpaper", "--group", "org.kde.image", "--group", "General", "--key", "Image", "file://" + rawPath])
} }
let rawPath = imgPath.replace("file://", "") let rawPath = imgPath.replace("file://", "")
Quickshell.execDetached(["sh", "-c", "wallust run '" + rawPath + "' || ~/.cargo/bin/wallust run '" + rawPath + "' 2>/dev/null || true"]) Quickshell.execDetached(["sh", "-c", "wallust run '" + rawPath + "' || ~/.cargo/bin/wallust run '" + rawPath + "' 2>/dev/null || true"])