feat(terra): Quickshell lock screen, Star Citizen, NexusMods, TeamSpeak
Also jellyfin-mpv-shim, mangohud logging, portal-backed xdg-open, systemd-resolved with fallback DNS, and keyring under the user manager. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,208 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Services.Pam
|
||||
import qs.HyprChrome.Widgets.Greeter
|
||||
|
||||
// ext-session-lock screen: the greeter's panel on every output, so whichever
|
||||
// one Hyprland gives the keyboard has a field. Runs as its own instance
|
||||
// (lock.qml) so a reload of the main shell cannot drop the lock; exits once
|
||||
// unlocked.
|
||||
Scope {
|
||||
id: root
|
||||
|
||||
readonly property string userName: Quickshell.env("USER") ?? ""
|
||||
readonly property string hostName: hostFile.text().trim() || "localhost"
|
||||
|
||||
// Typed password, held until PAM's first secret prompt arrives.
|
||||
property string pendingSecret: ""
|
||||
// PAM asked a follow-up (OTP etc.) that the user must answer directly.
|
||||
property bool awaitingResponse: false
|
||||
property bool busy: false
|
||||
property bool unlocking: false
|
||||
|
||||
property string message: ""
|
||||
property bool messageIsError: false
|
||||
property bool failed: false
|
||||
property string inputPrompt: ""
|
||||
property bool responseVisible: false
|
||||
property date now: new Date()
|
||||
|
||||
// Each surface keeps its own field; this resets all of them.
|
||||
signal resetSecret
|
||||
|
||||
function setMessage(text, isError) {
|
||||
root.message = text;
|
||||
root.messageIsError = isError;
|
||||
}
|
||||
|
||||
function resetToPassword() {
|
||||
root.pendingSecret = "";
|
||||
root.awaitingResponse = false;
|
||||
root.busy = false;
|
||||
root.inputPrompt = "";
|
||||
root.responseVisible = false;
|
||||
root.resetSecret();
|
||||
}
|
||||
|
||||
function submit(secret) {
|
||||
root.failed = false;
|
||||
|
||||
if (root.awaitingResponse) {
|
||||
root.awaitingResponse = false;
|
||||
root.busy = true;
|
||||
root.resetSecret();
|
||||
pam.respond(secret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pam.active)
|
||||
return;
|
||||
|
||||
root.setMessage("", false);
|
||||
root.pendingSecret = secret;
|
||||
root.busy = true;
|
||||
if (!pam.start()) {
|
||||
root.resetToPassword();
|
||||
root.setMessage("pam failed to start", true);
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: hostFile
|
||||
|
||||
path: "/etc/hostname"
|
||||
blockLoading: true
|
||||
}
|
||||
|
||||
PamContext {
|
||||
id: pam
|
||||
|
||||
// security.pam.services.hyprchrome-lock (services/desktop/desktop-hyprland.nix).
|
||||
config: "hyprchrome-lock"
|
||||
user: root.userName
|
||||
|
||||
onPamMessage: {
|
||||
if (!pam.responseRequired) {
|
||||
root.setMessage(pam.message, pam.messageIsError);
|
||||
return;
|
||||
}
|
||||
|
||||
// First hidden prompt is the password already typed.
|
||||
if (root.pendingSecret !== "" && !pam.responseVisible) {
|
||||
const secret = root.pendingSecret;
|
||||
root.pendingSecret = "";
|
||||
pam.respond(secret);
|
||||
return;
|
||||
}
|
||||
|
||||
root.busy = false;
|
||||
root.awaitingResponse = true;
|
||||
root.inputPrompt = pam.message.replace(/:\s*$/, "");
|
||||
root.responseVisible = pam.responseVisible;
|
||||
root.resetSecret();
|
||||
}
|
||||
|
||||
onCompleted: result => {
|
||||
if (result === PamResult.Success) {
|
||||
root.setMessage("unlocked", false);
|
||||
root.unlocking = true;
|
||||
return;
|
||||
}
|
||||
root.resetToPassword();
|
||||
root.failed = true;
|
||||
root.setMessage(result === PamResult.MaxTries ? "too many attempts" : "authentication failed", true);
|
||||
}
|
||||
|
||||
onError: error => {
|
||||
root.resetToPassword();
|
||||
root.setMessage(PamError.toString(error), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Fade out, then release the outputs. The quit is deferred so the unlock
|
||||
// request is flushed before the connection closes; exiting while still
|
||||
// locked would leave Hyprland's "lock app died" screen up.
|
||||
Timer {
|
||||
running: root.unlocking
|
||||
interval: 220
|
||||
onTriggered: {
|
||||
lock.locked = false;
|
||||
quitTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: quitTimer
|
||||
|
||||
interval: 100
|
||||
onTriggered: Qt.quit()
|
||||
}
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
interval: 1000
|
||||
triggeredOnStart: true
|
||||
onTriggered: root.now = new Date()
|
||||
}
|
||||
|
||||
WlSessionLock {
|
||||
id: lock
|
||||
|
||||
locked: true
|
||||
|
||||
WlSessionLockSurface {
|
||||
color: "transparent"
|
||||
|
||||
LockBackdrop {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
LoginContent {
|
||||
id: content
|
||||
|
||||
width: 640
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: Math.max(32, Math.round(parent.height * 0.42 - height / 2)) + (1 - opacity) * 12
|
||||
|
||||
opacity: root.unlocking ? 0 : 1
|
||||
Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutCubic } }
|
||||
|
||||
title: "LOCKED // " + root.hostName.toUpperCase()
|
||||
panelId: "LCK"
|
||||
meta: "PAM"
|
||||
submitLabel: "UNLOCK"
|
||||
userEditable: false
|
||||
showPower: false
|
||||
|
||||
hostName: root.hostName
|
||||
sessionName: "hyprland"
|
||||
user: root.userName
|
||||
now: root.now
|
||||
busy: root.busy || root.unlocking
|
||||
message: root.message
|
||||
messageIsError: root.messageIsError
|
||||
failed: root.failed
|
||||
inputPrompt: root.inputPrompt
|
||||
responseVisible: root.responseVisible
|
||||
|
||||
onSubmitted: (user, secret) => root.submit(secret)
|
||||
|
||||
Component.onCompleted: content.focusSecret()
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
|
||||
function onResetSecret() {
|
||||
content.clearSecret();
|
||||
content.focusSecret();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import qs.HyprChrome.Theme
|
||||
|
||||
// ChromeBackdrop's drafting grid at full dim, as a plain Item: a lock surface
|
||||
// cannot host a PanelWindow, and nothing behind it is shown anyway.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property int gridSpacing: 60
|
||||
property real gridOpacity: 0.10
|
||||
property real crossOpacity: 0.15
|
||||
property int crossSize: 20
|
||||
property int crossWeight: 3
|
||||
|
||||
readonly property color gridColor: Qt.hsla(Theme.accent.hslHue,
|
||||
Theme.accent.hslSaturation * 0.45,
|
||||
Theme.accent.hslLightness,
|
||||
1)
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.surface
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: Math.ceil(root.width / root.gridSpacing)
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
|
||||
x: index * root.gridSpacing
|
||||
width: 1
|
||||
height: root.height
|
||||
color: root.gridColor
|
||||
opacity: root.gridOpacity
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: Math.ceil(root.height / root.gridSpacing)
|
||||
|
||||
Rectangle {
|
||||
required property int index
|
||||
|
||||
y: index * root.gridSpacing
|
||||
width: root.width
|
||||
height: 1
|
||||
color: root.gridColor
|
||||
opacity: root.gridOpacity
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: crosses
|
||||
|
||||
readonly property int columns: Math.ceil(root.width / (root.gridSpacing * 2)) + 1
|
||||
readonly property int rows: Math.ceil(root.height / (root.gridSpacing * 2)) + 1
|
||||
model: columns * rows
|
||||
|
||||
Item {
|
||||
required property int index
|
||||
|
||||
x: (index % crosses.columns) * root.gridSpacing * 2 - Math.floor(root.crossSize / 2)
|
||||
y: Math.floor(index / crosses.columns) * root.gridSpacing * 2 - Math.floor(root.crossSize / 2)
|
||||
width: root.crossSize
|
||||
height: root.crossSize
|
||||
opacity: root.crossOpacity
|
||||
|
||||
Rectangle {
|
||||
y: Math.floor(root.crossSize / 2) - Math.floor(root.crossWeight / 2)
|
||||
width: parent.width
|
||||
height: root.crossWeight
|
||||
color: Theme.muted
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
x: Math.floor(root.crossSize / 2) - Math.floor(root.crossWeight / 2)
|
||||
width: root.crossWeight
|
||||
height: parent.height
|
||||
color: Theme.muted
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user