This commit is contained in:
Ly-sec 2025-08-24 19:38:35 +02:00
parent 76626dc8da
commit 37dad3a255
4 changed files with 884 additions and 773 deletions

View file

@ -3,90 +3,90 @@ import Quickshell
import Quickshell.Services.Pam import Quickshell.Services.Pam
Scope { Scope {
id: root id: root
signal unlocked() signal unlocked
signal failed() signal failed
property string currentText: "" property string currentText: ""
property bool unlockInProgress: false property bool unlockInProgress: false
property bool showFailure: false property bool showFailure: false
property string errorMessage: "" property string errorMessage: ""
property bool pamAvailable: typeof PamContext !== "undefined" property bool pamAvailable: typeof PamContext !== "undefined"
onCurrentTextChanged: { onCurrentTextChanged: {
if (currentText !== "") { if (currentText !== "") {
showFailure = false; showFailure = false
errorMessage = ""; errorMessage = ""
} }
}
function tryUnlock() {
if (!pamAvailable) {
errorMessage = "PAM not available"
showFailure = true
return
} }
function tryUnlock() { if (currentText === "") {
if (!pamAvailable) { errorMessage = "Password required"
errorMessage = "PAM not available"; showFailure = true
showFailure = true; return
return;
}
if (currentText === "") {
errorMessage = "Password required";
showFailure = true;
return;
}
root.unlockInProgress = true;
errorMessage = "";
showFailure = false;
console.log("Starting PAM authentication for user:", pam.user);
pam.start();
} }
PamContext { root.unlockInProgress = true
id: pam errorMessage = ""
config: "login" showFailure = false
user: Quickshell.env("USER")
onPamMessage: { console.log("Starting PAM authentication for user:", pam.user)
console.log("PAM message:", message, "isError:", messageIsError, "responseRequired:", responseRequired); pam.start()
}
if (messageIsError) { PamContext {
errorMessage = message; id: pam
} config: "login"
user: Quickshell.env("USER")
if (responseRequired) { onPamMessage: {
console.log("Responding to PAM with password"); console.log("PAM message:", message, "isError:", messageIsError, "responseRequired:", responseRequired)
respond(root.currentText);
}
}
onResponseRequiredChanged: { if (messageIsError) {
console.log("Response required changed:", responseRequired); errorMessage = message
if (responseRequired && root.unlockInProgress) { }
console.log("Automatically responding to PAM");
respond(root.currentText);
}
}
onCompleted: { if (responseRequired) {
console.log("PAM completed with result:", result); console.log("Responding to PAM with password")
if (result === PamResult.Success) { respond(root.currentText)
console.log("Authentication successful"); }
root.unlocked();
} else {
console.log("Authentication failed");
errorMessage = "Authentication failed";
showFailure = true;
root.failed();
}
root.unlockInProgress = false;
}
onError: {
console.log("PAM error:", error, "message:", message);
errorMessage = message || "Authentication error";
showFailure = true;
root.unlockInProgress = false;
root.failed();
}
} }
onResponseRequiredChanged: {
console.log("Response required changed:", responseRequired)
if (responseRequired && root.unlockInProgress) {
console.log("Automatically responding to PAM")
respond(root.currentText)
}
}
onCompleted: {
console.log("PAM completed with result:", result)
if (result === PamResult.Success) {
console.log("Authentication successful")
root.unlocked()
} else {
console.log("Authentication failed")
errorMessage = "Authentication failed"
showFailure = true
root.failed()
}
root.unlockInProgress = false
}
onError: {
console.log("PAM error:", error, "message:", message)
errorMessage = message || "Authentication error"
showFailure = true
root.unlockInProgress = false
root.failed()
}
}
} }

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,7 @@ Variants {
// Only show on screens that have notifications enabled // Only show on screens that have notifications enabled
visible: modelData ? (Settings.data.notifications.monitors.includes(modelData.name) visible: modelData ? (Settings.data.notifications.monitors.includes(modelData.name)
|| (Settings.data.notifications.monitors.length === 0)) : false || (Settings.data.notifications.monitors.length === 0)) : false
// Position based on bar location, like Notification popup does // Position based on bar location, like Notification popup does
anchors { anchors {
@ -57,7 +57,7 @@ Variants {
Component.onCompleted: { Component.onCompleted: {
// Only register toasts for screens that have notifications enabled // Only register toasts for screens that have notifications enabled
if (modelData ? (Settings.data.notifications.monitors.includes(modelData.name) if (modelData ? (Settings.data.notifications.monitors.includes(modelData.name)
|| (Settings.data.notifications.monitors.length === 0)) : false) { || (Settings.data.notifications.monitors.length === 0)) : false) {
// Register this toast with the service // Register this toast with the service
ToastService.allToasts.push(toast) ToastService.allToasts.push(toast)