Move quickshell to its own module
This commit is contained in:
parent
1dd031aa6b
commit
b6bff47ed1
9 changed files with 34 additions and 30 deletions
|
@ -69,6 +69,7 @@
|
|||
homeConfig = homeInputs.config;
|
||||
in {
|
||||
imports = [
|
||||
./modules/quickshell
|
||||
./modules/fcitx5
|
||||
./modules/wofi
|
||||
./modules/dolphin
|
||||
|
|
12
modules/user/modules/quickshell/default.nix
Normal file
12
modules/user/modules/quickshell/default.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ inputs, pkgs, lib, system, impurity, ... }: let
|
||||
inherit (inputs) quickshell;
|
||||
in {
|
||||
home.packages = [
|
||||
quickshell.packages.${system}.default
|
||||
pamtester # lockscreen
|
||||
];
|
||||
|
||||
xdg.configFile."quickshell/manifest.conf".text = lib.generators.toKeyValue {} {
|
||||
lockscreen = impurity.link ./lockscreen;
|
||||
};
|
||||
}
|
43
modules/user/modules/quickshell/lockscreen/AuthContext.qml
Normal file
43
modules/user/modules/quickshell/lockscreen/AuthContext.qml
Normal file
|
@ -0,0 +1,43 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
QtObject {
|
||||
property int status: AuthContext.Status.FirstLogin
|
||||
signal unlocked();
|
||||
|
||||
enum Status {
|
||||
FirstLogin,
|
||||
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 {
|
||||
unlocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function tryLogin(password: string) {
|
||||
this.password = password
|
||||
status = AuthContext.Status.Authenticating;
|
||||
pamtester.running = true;
|
||||
}
|
||||
}
|
51
modules/user/modules/quickshell/lockscreen/Lockscreen.qml
Normal file
51
modules/user/modules/quickshell/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.FirstLogin: return ""
|
||||
case AuthContext.Status.Authenticating: return "Authenticating"
|
||||
case AuthContext.Status.LoginFailed: return "Login Failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
modules/user/modules/quickshell/lockscreen/shell.qml
Normal file
32
modules/user/modules/quickshell/lockscreen/shell.qml
Normal file
|
@ -0,0 +1,32 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
ShellRoot {
|
||||
AuthContext {
|
||||
id: authContext
|
||||
onUnlocked: lock.locked = false
|
||||
}
|
||||
|
||||
SessionLock {
|
||||
id: lock
|
||||
locked: true
|
||||
|
||||
onLockedChanged: {
|
||||
if (!locked) Qt.quit();
|
||||
}
|
||||
|
||||
SessionLockSurface {
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: `../../../../hyprland/${screen.name == "DP-1" ? "5120x1440" : "1920x1080"}.png`
|
||||
}
|
||||
|
||||
Lockscreen {
|
||||
anchors.fill: parent
|
||||
context: authContext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
18
modules/user/modules/quickshell/lockscreen/test.qml
Normal file
18
modules/user/modules/quickshell/lockscreen/test.qml
Normal file
|
@ -0,0 +1,18 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
|
||||
ShellRoot {
|
||||
AuthContext {
|
||||
id: authContext
|
||||
onUnlocked: Qt.quit()
|
||||
}
|
||||
|
||||
FloatingWindow {
|
||||
color: "#303030"
|
||||
|
||||
Lockscreen {
|
||||
anchors.fill: parent
|
||||
context: authContext
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue