use wallpaper from swaybg
This commit is contained in:
parent
56cba97339
commit
b5e5ecf2f3
6 changed files with 43 additions and 13 deletions
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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} "$@"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
39
src/Lock.qml
39
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -14,6 +14,4 @@ Singleton {
|
|||
readonly property color subtext: "#d8dee9"
|
||||
|
||||
readonly property string font: "Inter"
|
||||
|
||||
readonly property string wallpaper: Quickshell.env("QUADSHELL_WALLPAPER") ?? ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue