Make lock screen behave like a lock screen
This commit is contained in:
@@ -24,6 +24,8 @@ Item {
|
||||
readonly property int fieldFontSize: Style.font.heading
|
||||
|
||||
signal submitPassword(string password)
|
||||
signal clearFailureRequested()
|
||||
signal wakeRequested()
|
||||
|
||||
function withAlpha(color, alpha) {
|
||||
return Qt.rgba(color.r, color.g, color.b, alpha)
|
||||
@@ -79,7 +81,9 @@ Item {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.forcePasswordFocus()
|
||||
hoverEnabled: true
|
||||
onClicked: { root.wakeRequested(); root.forcePasswordFocus() }
|
||||
onPositionChanged: root.wakeRequested()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -115,8 +119,11 @@ Item {
|
||||
cursorVisible: activeFocus && !root.authenticatingPassword && root.hasTyped
|
||||
|
||||
onTextChanged: {
|
||||
if (text.length > 0) root.hasTyped = true
|
||||
if (text.length > 0 && root.failureMessage.length > 0) root.failureMessage = ""
|
||||
if (text.length > 0) {
|
||||
root.hasTyped = true
|
||||
root.wakeRequested()
|
||||
}
|
||||
if (text.length > 0 && root.failureMessage.length > 0) root.clearFailureRequested()
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
@@ -127,6 +134,7 @@ Item {
|
||||
}
|
||||
|
||||
Keys.onPressed: function(event) {
|
||||
root.wakeRequested()
|
||||
if (event.key === Qt.Key_Escape || (event.modifiers & Qt.ControlModifier && event.key === Qt.Key_U)) {
|
||||
text = ""
|
||||
root.hasTyped = false
|
||||
@@ -137,12 +145,12 @@ Item {
|
||||
|
||||
Text {
|
||||
anchors.fill: passwordInput
|
||||
text: root.failureMessage.length > 0 ? root.failureMessage : root.placeholderText
|
||||
text: root.authenticatingPassword ? "Checking…" : (root.failureMessage.length > 0 ? root.failureMessage : root.placeholderText)
|
||||
visible: passwordInput.text.length === 0
|
||||
color: root.failureMessage.length > 0 ? Color.lock.textError : Color.lock.text
|
||||
color: (!root.authenticatingPassword && root.failureMessage.length > 0) ? Color.lock.textError : Color.lock.text
|
||||
font.family: "monospace"
|
||||
font.pixelSize: root.fieldFontSize
|
||||
font.italic: root.failureMessage.length > 0
|
||||
font.italic: !root.authenticatingPassword && root.failureMessage.length > 0
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
|
||||
@@ -57,6 +57,7 @@ Item {
|
||||
refreshFingerprintStatus()
|
||||
lockRequested = true
|
||||
sessionLock.locked = true
|
||||
idleBlankTimer.restart()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -65,18 +66,25 @@ Item {
|
||||
|
||||
lockRequested = false
|
||||
resetAuthenticationState()
|
||||
idleBlankTimer.stop()
|
||||
sessionLock.locked = false
|
||||
runWake()
|
||||
}
|
||||
|
||||
function runWake() {
|
||||
if (!wakeProcess.running) wakeProcess.running = true
|
||||
if (lockRequested) idleBlankTimer.restart()
|
||||
}
|
||||
|
||||
function runBlank() {
|
||||
if (!blankProcess.running) blankProcess.running = true
|
||||
}
|
||||
|
||||
function submitPassword(value) {
|
||||
var password = String(value || "")
|
||||
if (!lockRequested || authenticatingPassword || password.length === 0) return
|
||||
|
||||
runWake()
|
||||
pendingPassword = password
|
||||
failureMessage = ""
|
||||
authenticatingPassword = true
|
||||
@@ -101,6 +109,7 @@ Item {
|
||||
pendingPassword = ""
|
||||
failedAttempts += 1
|
||||
failureMessage = "Authentication failed (" + failedAttempts + ")"
|
||||
runWake()
|
||||
}
|
||||
|
||||
function startFingerprint() {
|
||||
@@ -157,6 +166,8 @@ Item {
|
||||
inputEnabled: root.lockRequested
|
||||
scaleFactor: lockSurface.screen && lockSurface.screen.devicePixelRatio > 0 ? lockSurface.screen.devicePixelRatio : 1
|
||||
onSubmitPassword: function(password) { root.submitPassword(password) }
|
||||
onClearFailureRequested: root.failureMessage = ""
|
||||
onWakeRequested: root.runWake()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -266,6 +277,24 @@ Item {
|
||||
command: ["bash", "-lc", "omarchy-system-wake"]
|
||||
}
|
||||
|
||||
Process {
|
||||
id: blankProcess
|
||||
command: ["bash", "-lc", "omarchy-brightness-keyboard off; omarchy-brightness-display off"]
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: idleBlankTimer
|
||||
interval: 30000
|
||||
repeat: false
|
||||
onTriggered: if (root.lockRequested && !root.authenticating) root.runBlank()
|
||||
}
|
||||
|
||||
onAuthenticatingChanged: {
|
||||
if (!lockRequested) return
|
||||
if (authenticating) idleBlankTimer.stop()
|
||||
else idleBlankTimer.restart()
|
||||
}
|
||||
|
||||
FileView {
|
||||
path: "/etc/pam.d/omarchy-lock-password"
|
||||
watchChanges: true
|
||||
|
||||
Reference in New Issue
Block a user