formatter

This commit is contained in:
Zacharias-Brohn
2026-02-24 23:20:11 +01:00
parent 40cd984b6d
commit d56a0260fb
202 changed files with 15037 additions and 15352 deletions
+150 -149
View File
@@ -6,188 +6,189 @@ import QtQuick
import qs.Config
Scope {
id: root
id: root
required property WlSessionLock lock
property string buffer
readonly property alias fprint: fprint
property string fprintState
required property WlSessionLock lock
property string lockMessage
readonly property alias passwd: passwd
property string state
readonly property alias passwd: passwd
readonly property alias fprint: fprint
property string lockMessage
property string state
property string fprintState
property string buffer
signal flashMsg
signal flashMsg
function handleKey(event: KeyEvent): void {
if (passwd.active || state === "max")
return;
function handleKey(event: KeyEvent): void {
if (passwd.active || state === "max")
return;
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
passwd.start();
} else if (event.key === Qt.Key_Backspace) {
if (event.modifiers & Qt.ControlModifier) {
buffer = "";
} else {
buffer = buffer.slice(0, -1);
}
} else if (" abcdefghijklmnopqrstuvwxyz1234567890`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?".includes(event.text.toLowerCase())) {
// No illegal characters (you are insane if you use unicode in your password)
buffer += event.text;
}
}
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
passwd.start();
} else if (event.key === Qt.Key_Backspace) {
if (event.modifiers & Qt.ControlModifier) {
buffer = "";
} else {
buffer = buffer.slice(0, -1);
}
} else if (" abcdefghijklmnopqrstuvwxyz1234567890`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?".includes(event.text.toLowerCase())) {
// No illegal characters (you are insane if you use unicode in your password)
buffer += event.text;
}
}
PamContext {
id: passwd
PamContext {
id: passwd
config: "passwd"
configDirectory: Quickshell.shellDir + "/assets/pam.d"
config: "passwd"
configDirectory: Quickshell.shellDir + "/assets/pam.d"
onCompleted: res => {
if (res === PamResult.Success)
return root.lock.unlock();
onMessageChanged: {
if (message.startsWith("The account is locked"))
root.lockMessage = message;
else if (root.lockMessage && message.endsWith(" left to unlock)"))
root.lockMessage += "\n" + message;
}
if (res === PamResult.Error)
root.state = "error";
else if (res === PamResult.MaxTries)
root.state = "max";
else if (res === PamResult.Failed)
root.state = "fail";
onResponseRequiredChanged: {
if (!responseRequired)
return;
root.flashMsg();
stateReset.restart();
}
onMessageChanged: {
if (message.startsWith("The account is locked"))
root.lockMessage = message;
else if (root.lockMessage && message.endsWith(" left to unlock)"))
root.lockMessage += "\n" + message;
}
onResponseRequiredChanged: {
if (!responseRequired)
return;
respond(root.buffer);
root.buffer = "";
}
respond(root.buffer);
root.buffer = "";
}
}
onCompleted: res => {
if (res === PamResult.Success)
return root.lock.unlock();
PamContext {
id: fprint
if (res === PamResult.Error)
root.state = "error";
else if (res === PamResult.MaxTries)
root.state = "max";
else if (res === PamResult.Failed)
root.state = "fail";
property bool available
property int errorTries
property int tries
root.flashMsg();
stateReset.restart();
}
}
function checkAvail(): void {
if (!available || !Config.lock.enableFprint || !root.lock.secure) {
abort();
return;
}
PamContext {
id: fprint
tries = 0;
errorTries = 0;
start();
}
property bool available
property int tries
property int errorTries
config: "fprint"
configDirectory: Quickshell.shellDir + "/assets/pam.d"
function checkAvail(): void {
if (!available || !Config.lock.enableFprint || !root.lock.secure) {
abort();
return;
}
onCompleted: res => {
if (!available)
return;
tries = 0;
errorTries = 0;
start();
}
if (res === PamResult.Success)
return root.lock.unlock();
config: "fprint"
configDirectory: Quickshell.shellDir + "/assets/pam.d"
if (res === PamResult.Error) {
root.fprintState = "error";
errorTries++;
if (errorTries < 5) {
abort();
errorRetry.restart();
}
} else if (res === PamResult.MaxTries) {
// Isn't actually the real max tries as pam only reports completed
// when max tries is reached.
tries++;
if (tries < Config.lock.maxFprintTries) {
// Restart if not actually real max tries
root.fprintState = "fail";
start();
} else {
root.fprintState = "max";
abort();
}
}
onCompleted: res => {
if (!available)
return;
root.flashMsg();
fprintStateReset.start();
}
}
if (res === PamResult.Success)
return root.lock.unlock();
Process {
id: availProc
if (res === PamResult.Error) {
root.fprintState = "error";
errorTries++;
if (errorTries < 5) {
abort();
errorRetry.restart();
}
} else if (res === PamResult.MaxTries) {
// Isn't actually the real max tries as pam only reports completed
// when max tries is reached.
tries++;
if (tries < Config.lock.maxFprintTries) {
// Restart if not actually real max tries
root.fprintState = "fail";
start();
} else {
root.fprintState = "max";
abort();
}
}
command: ["sh", "-c", "fprintd-list $USER"]
root.flashMsg();
fprintStateReset.start();
}
}
onExited: code => {
fprint.available = code === 0;
fprint.checkAvail();
}
}
Process {
id: availProc
Timer {
id: errorRetry
command: ["sh", "-c", "fprintd-list $USER"]
onExited: code => {
fprint.available = code === 0;
fprint.checkAvail();
}
}
interval: 800
Timer {
id: errorRetry
onTriggered: fprint.start()
}
interval: 800
onTriggered: fprint.start()
}
Timer {
id: stateReset
Timer {
id: stateReset
interval: 4000
interval: 4000
onTriggered: {
if (root.state !== "max")
root.state = "";
}
}
onTriggered: {
if (root.state !== "max")
root.state = "";
}
}
Timer {
id: fprintStateReset
Timer {
id: fprintStateReset
interval: 4000
onTriggered: {
root.fprintState = "";
fprint.errorTries = 0;
}
}
interval: 4000
Connections {
target: root.lock
onTriggered: {
root.fprintState = "";
fprint.errorTries = 0;
}
}
function onSecureChanged(): void {
if (root.lock.secure) {
availProc.running = true;
root.buffer = "";
root.state = "";
root.fprintState = "";
root.lockMessage = "";
}
}
Connections {
function onSecureChanged(): void {
if (root.lock.secure) {
availProc.running = true;
root.buffer = "";
root.state = "";
root.fprintState = "";
root.lockMessage = "";
}
}
function onUnlock(): void {
fprint.abort();
}
}
function onUnlock(): void {
fprint.abort();
}
Connections {
target: Config.lock
target: root.lock
}
function onEnableFprintChanged(): void {
fprint.checkAvail();
}
}
Connections {
function onEnableFprintChanged(): void {
fprint.checkAvail();
}
target: Config.lock
}
}