diff --git a/README.md b/README.md index afa3c83..29421a7 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,7 @@ Then start it with niri, in your niri config: spawn-at-startup "quadshell" ``` -To have your wallpaper blurred behind the lockscreen, use -`pkgs.quadshell.override { wallpaper = ./background.jpg; }`. It sets `QUADSHELL_WALLPAPER`, -which you can also set yourself, or before `nix run .#phone` to a path on the phone. +The lockscreen shows whatever image swaybg is showing (its `-i` argument), blurred. It brings `nmcli`, `mmcli`, `nmgui` and `adw-bluetooth` with it. The system needs: diff --git a/flake.nix b/flake.nix index 331643e..db02f5f 100644 --- a/flake.nix +++ b/flake.nix @@ -50,9 +50,7 @@ exec ssh -t "$host" " nix-store --realise ${builtins.dirOf (builtins.dirOf quickshell)} >/dev/null; pkill -f '^/nix/store/[^ ]*/bin/quickshell '; - exec systemd-run --user --pty --quiet --collect \ - ''${QUADSHELL_WALLPAPER:+--setenv=QUADSHELL_WALLPAPER=$QUADSHELL_WALLPAPER} \ - ${quickshell} --path ~/$dest + exec systemd-run --user --pty --quiet --collect ${quickshell} --path ~/$dest " ''; } diff --git a/package.nix b/package.nix index 64885d0..2c4a990 100644 --- a/package.nix +++ b/package.nix @@ -10,8 +10,7 @@ coreutils, gawk, gnugrep, - # Blurred behind the lockscreen - wallpaper ? null, + procps, }: let config = lib.fileset.toSource { @@ -31,10 +30,10 @@ writeShellApplication { gawk gnugrep glib # gdbus, for logind's lock signal + procps # pgrep, for the wallpaper swaybg is showing ]; text = '' - ${lib.optionalString (wallpaper != null) "export QUADSHELL_WALLPAPER=${wallpaper}"} exec ${lib.getExe quickshell} --path ${config} "$@" ''; } diff --git a/src/Lock.qml b/src/Lock.qml index c55e9e6..b38987e 100644 --- a/src/Lock.qml +++ b/src/Lock.qml @@ -12,6 +12,7 @@ Scope { property string error: "" property string password property string sessionPath + property string wallpaper signal failed @@ -26,6 +27,11 @@ Scope { pam.start(); } + function findWallpaper() { + wallpaperTimer.tries = 0; + wallpaperTimer.restart(); + } + function setLockedHint() { if (sessionPath === "") return; Quickshell.execDetached(["busctl", "call", "org.freedesktop.login1", sessionPath, @@ -37,7 +43,10 @@ Scope { WlSessionLock { id: session locked: true - onLockedChanged: root.setLockedHint() + onLockedChanged: { + root.setLockedHint(); + if (locked) root.findWallpaper(); + } LockSurface { lock: root @@ -88,6 +97,34 @@ Scope { onRunningChanged: if (!running) restartLogind.start() } + Process { + id: swaybg + command: ["pgrep", "-a", "swaybg"] + stdout: StdioCollector { + onStreamFinished: { + const image = text.match(/(?:-i|--image) (\S+)/)?.[1]; + if (image) root.wallpaper = image; + } + } + } + + Timer { + id: wallpaperTimer + property int tries + running: true + triggeredOnStart: true + repeat: true + interval: 1000 + onTriggered: { + if (tries > 0 && root.wallpaper !== "" || tries >= 10) { + stop(); + } else { + tries++; + swaybg.running = true; + } + } + } + Timer { id: restartLogind interval: 2000 diff --git a/src/LockSurface.qml b/src/LockSurface.qml index 2f9fd19..b4e0bd4 100644 --- a/src/LockSurface.qml +++ b/src/LockSurface.qml @@ -20,7 +20,7 @@ WlSessionLockSurface { anchors.fill: parent anchors.margins: -blur.blurMax visible: false - source: Theme.wallpaper === "" ? "" : `file://${Theme.wallpaper}` + source: surface.lock.wallpaper === "" ? "" : `file://${surface.lock.wallpaper}` fillMode: Image.PreserveAspectCrop sourceSize.width: surface.width / 2 asynchronous: true diff --git a/src/Theme.qml b/src/Theme.qml index 6823074..edc43b9 100644 --- a/src/Theme.qml +++ b/src/Theme.qml @@ -14,6 +14,4 @@ Singleton { readonly property color subtext: "#d8dee9" readonly property string font: "Inter" - - readonly property string wallpaper: Quickshell.env("QUADSHELL_WALLPAPER") ?? "" }