Quickshell lockscreen
This commit is contained in:
parent
2de8a9e979
commit
d388842a87
|
@ -1,5 +1,5 @@
|
||||||
{ system, inputs, impurity, lib, config, pkgs, ... }: let
|
{ system, inputs, impurity, lib, config, pkgs, ... }: let
|
||||||
inherit (inputs) hyprland hyprpaper hyprland-hy3;
|
inherit (inputs) hyprland hyprpaper hyprland-hy3 quickshell;
|
||||||
|
|
||||||
# I blame home manager
|
# I blame home manager
|
||||||
wrapper = pkgs.callPackage ({ ... }: pkgs.writeShellScriptBin "hyprland" ''
|
wrapper = pkgs.callPackage ({ ... }: pkgs.writeShellScriptBin "hyprland" ''
|
||||||
|
@ -52,6 +52,10 @@ in {
|
||||||
wrapper
|
wrapper
|
||||||
hyprpaper
|
hyprpaper
|
||||||
|
|
||||||
|
pamtester # quickshell lockscreen
|
||||||
|
quickshell.packages.${system}.default
|
||||||
|
(writeShellScriptBin "quickshell-lock" "quickshell -c ${impurity.link ./lockscreen/shell.qml}")
|
||||||
|
|
||||||
# environment programs
|
# environment programs
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
grim
|
grim
|
||||||
|
|
|
@ -163,6 +163,8 @@ bind = ,XF86AudioPrev, exec, playerctl previous
|
||||||
|
|
||||||
bind = $mod+SHIFT, s, exec, grim -g "$(slurp)" - | wl-copy
|
bind = $mod+SHIFT, s, exec, grim -g "$(slurp)" - | wl-copy
|
||||||
|
|
||||||
|
bind = $mod, PERIOD, exec, quickshell-lock
|
||||||
|
|
||||||
bind = $mod, h, hy3:movefocus, l
|
bind = $mod, h, hy3:movefocus, l
|
||||||
bind = $mod, j, hy3:movefocus, d
|
bind = $mod, j, hy3:movefocus, d
|
||||||
bind = $mod, k, hy3:movefocus, u
|
bind = $mod, k, hy3:movefocus, u
|
||||||
|
|
43
modules/hyprland/lockscreen/AuthContext.qml
Normal file
43
modules/hyprland/lockscreen/AuthContext.qml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property int status: AuthContext.Status.FirstEntry
|
||||||
|
signal success();
|
||||||
|
|
||||||
|
enum Status {
|
||||||
|
FirstEntry,
|
||||||
|
Authenticating,
|
||||||
|
LoginFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
property string password
|
||||||
|
|
||||||
|
property var pamtester: Process {
|
||||||
|
property bool failed: true
|
||||||
|
|
||||||
|
command: ["pamtester", "login", Quickshell.env("USER"), "authenticate"]
|
||||||
|
|
||||||
|
onStarted: this.write(`${password}\n`)
|
||||||
|
|
||||||
|
stdout: SplitParser {
|
||||||
|
// fails go to stderr
|
||||||
|
onRead: pamtester.failed = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
if (failed) {
|
||||||
|
status = AuthContext.Status.LoginFailed
|
||||||
|
} else {
|
||||||
|
success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tryLogin(password: string) {
|
||||||
|
this.password = password
|
||||||
|
status = AuthContext.Status.Authenticating;
|
||||||
|
pamtester.running = true;
|
||||||
|
}
|
||||||
|
}
|
51
modules/hyprland/lockscreen/Lockscreen.qml
Normal file
51
modules/hyprland/lockscreen/Lockscreen.qml
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls.Universal
|
||||||
|
|
||||||
|
Item {
|
||||||
|
required property AuthContext context
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
scale: 2
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: entryBox
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 300
|
||||||
|
|
||||||
|
enabled: context.status != AuthContext.Status.Authenticating
|
||||||
|
focus: true
|
||||||
|
horizontalAlignment: TextInput.AlignHCenter
|
||||||
|
echoMode: TextInput.Password
|
||||||
|
inputMethodHints: Qt.ImhSensitiveData
|
||||||
|
placeholderText: "Enter password"
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
if (text != "") context.tryLogin(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnabledChanged: {
|
||||||
|
if (enabled) text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: status
|
||||||
|
color: "white"
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: entryBox.horizontalCenter
|
||||||
|
top: entryBox.bottom
|
||||||
|
topMargin: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
text: {
|
||||||
|
switch (context.status) {
|
||||||
|
case AuthContext.Status.FirstEntry: return ""
|
||||||
|
case AuthContext.Status.Authenticating: return "Authenticating"
|
||||||
|
case AuthContext.Status.LoginFailed: return "Login Failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
modules/hyprland/lockscreen/shell.qml
Normal file
32
modules/hyprland/lockscreen/shell.qml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Wayland
|
||||||
|
|
||||||
|
ShellRoot {
|
||||||
|
AuthContext {
|
||||||
|
id: authContext
|
||||||
|
onSuccess: {
|
||||||
|
lock.locked = false;
|
||||||
|
Qt.quit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionLock {
|
||||||
|
id: lock
|
||||||
|
locked: true
|
||||||
|
|
||||||
|
SessionLockSurface {
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: screen.name == "DP-1" ? "../5120x1440.png" : "../1920x1080.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
Lockscreen {
|
||||||
|
anchors.fill: parent
|
||||||
|
context: authContext
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
modules/hyprland/lockscreen/test.qml
Normal file
21
modules/hyprland/lockscreen/test.qml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
|
||||||
|
ShellRoot {
|
||||||
|
AuthContext {
|
||||||
|
id: authContext
|
||||||
|
onSuccess: Qt.quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
FloatingWindow {
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: "../1920x1080.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
Lockscreen {
|
||||||
|
anchors.fill: parent
|
||||||
|
context: authContext
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue