Make lock screen behave like a lock screen

This commit is contained in:
Ryan Hughes
2026-05-19 17:20:45 -04:00
parent 201a003537
commit 72c9331c72
3 changed files with 43 additions and 15 deletions
-9
View File
@@ -17,12 +17,3 @@ fi
# Avoid running screensaver when locked # Avoid running screensaver when locked
pkill -f '[o]rg.omarchy.screensaver' pkill -f '[o]rg.omarchy.screensaver'
if [[ ${OMARCHY_LOCK_ONLY:-false} != "true" ]]; then
(
sleep 3
[[ $(omarchy-shell lock isLocked 2>/dev/null) == "true" ]] || exit 0
omarchy-brightness-keyboard off
omarchy-brightness-display off
) &
fi
+14 -6
View File
@@ -24,6 +24,8 @@ Item {
readonly property int fieldFontSize: Style.font.heading readonly property int fieldFontSize: Style.font.heading
signal submitPassword(string password) signal submitPassword(string password)
signal clearFailureRequested()
signal wakeRequested()
function withAlpha(color, alpha) { function withAlpha(color, alpha) {
return Qt.rgba(color.r, color.g, color.b, alpha) return Qt.rgba(color.r, color.g, color.b, alpha)
@@ -79,7 +81,9 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: root.forcePasswordFocus() hoverEnabled: true
onClicked: { root.wakeRequested(); root.forcePasswordFocus() }
onPositionChanged: root.wakeRequested()
} }
Rectangle { Rectangle {
@@ -115,8 +119,11 @@ Item {
cursorVisible: activeFocus && !root.authenticatingPassword && root.hasTyped cursorVisible: activeFocus && !root.authenticatingPassword && root.hasTyped
onTextChanged: { onTextChanged: {
if (text.length > 0) root.hasTyped = true if (text.length > 0) {
if (text.length > 0 && root.failureMessage.length > 0) root.failureMessage = "" root.hasTyped = true
root.wakeRequested()
}
if (text.length > 0 && root.failureMessage.length > 0) root.clearFailureRequested()
} }
onAccepted: { onAccepted: {
@@ -127,6 +134,7 @@ Item {
} }
Keys.onPressed: function(event) { Keys.onPressed: function(event) {
root.wakeRequested()
if (event.key === Qt.Key_Escape || (event.modifiers & Qt.ControlModifier && event.key === Qt.Key_U)) { if (event.key === Qt.Key_Escape || (event.modifiers & Qt.ControlModifier && event.key === Qt.Key_U)) {
text = "" text = ""
root.hasTyped = false root.hasTyped = false
@@ -137,12 +145,12 @@ Item {
Text { Text {
anchors.fill: passwordInput 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 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.family: "monospace"
font.pixelSize: root.fieldFontSize font.pixelSize: root.fieldFontSize
font.italic: root.failureMessage.length > 0 font.italic: !root.authenticatingPassword && root.failureMessage.length > 0
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight elide: Text.ElideRight
+29
View File
@@ -57,6 +57,7 @@ Item {
refreshFingerprintStatus() refreshFingerprintStatus()
lockRequested = true lockRequested = true
sessionLock.locked = true sessionLock.locked = true
idleBlankTimer.restart()
return true return true
} }
@@ -65,18 +66,25 @@ Item {
lockRequested = false lockRequested = false
resetAuthenticationState() resetAuthenticationState()
idleBlankTimer.stop()
sessionLock.locked = false sessionLock.locked = false
runWake() runWake()
} }
function runWake() { function runWake() {
if (!wakeProcess.running) wakeProcess.running = true if (!wakeProcess.running) wakeProcess.running = true
if (lockRequested) idleBlankTimer.restart()
}
function runBlank() {
if (!blankProcess.running) blankProcess.running = true
} }
function submitPassword(value) { function submitPassword(value) {
var password = String(value || "") var password = String(value || "")
if (!lockRequested || authenticatingPassword || password.length === 0) return if (!lockRequested || authenticatingPassword || password.length === 0) return
runWake()
pendingPassword = password pendingPassword = password
failureMessage = "" failureMessage = ""
authenticatingPassword = true authenticatingPassword = true
@@ -101,6 +109,7 @@ Item {
pendingPassword = "" pendingPassword = ""
failedAttempts += 1 failedAttempts += 1
failureMessage = "Authentication failed (" + failedAttempts + ")" failureMessage = "Authentication failed (" + failedAttempts + ")"
runWake()
} }
function startFingerprint() { function startFingerprint() {
@@ -157,6 +166,8 @@ Item {
inputEnabled: root.lockRequested inputEnabled: root.lockRequested
scaleFactor: lockSurface.screen && lockSurface.screen.devicePixelRatio > 0 ? lockSurface.screen.devicePixelRatio : 1 scaleFactor: lockSurface.screen && lockSurface.screen.devicePixelRatio > 0 ? lockSurface.screen.devicePixelRatio : 1
onSubmitPassword: function(password) { root.submitPassword(password) } onSubmitPassword: function(password) { root.submitPassword(password) }
onClearFailureRequested: root.failureMessage = ""
onWakeRequested: root.runWake()
} }
} }
@@ -266,6 +277,24 @@ Item {
command: ["bash", "-lc", "omarchy-system-wake"] 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 { FileView {
path: "/etc/pam.d/omarchy-lock-password" path: "/etc/pam.d/omarchy-lock-password"
watchChanges: true watchChanges: true