Initial commit
This commit is contained in:
commit
f94fd70f07
151 changed files with 7650 additions and 0 deletions
25
quickshell/lock/Colours.qml
Normal file
25
quickshell/lock/Colours.qml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
pragma Singleton
|
||||
|
||||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
readonly property string foreground: "#FDF8F0"
|
||||
readonly property string background: "#151313"
|
||||
|
||||
readonly property string colour0: "#3F3D3D"
|
||||
readonly property string colour1: "#51494A"
|
||||
readonly property string colour2: "#866F67"
|
||||
readonly property string colour3: "#808578"
|
||||
readonly property string colour4: "#897E6B"
|
||||
readonly property string colour5: "#EEDA8D"
|
||||
readonly property string colour6: "#F9ECD4"
|
||||
readonly property string colour7: "#F4EDE1"
|
||||
readonly property string colour8: "#ABA69D"
|
||||
readonly property string colour9: "#51494A"
|
||||
readonly property string colour10: "#866F67"
|
||||
readonly property string colour11: "#808578"
|
||||
readonly property string colour12: "#897E6B"
|
||||
readonly property string colour13: "#EEDA8D"
|
||||
readonly property string colour14: "#F9ECD4"
|
||||
readonly property string colour15: "#F4EDE1"
|
||||
}
|
||||
54
quickshell/lock/LockContext.qml
Normal file
54
quickshell/lock/LockContext.qml
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Pam
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
signal unlocked()
|
||||
signal failed()
|
||||
|
||||
// These properties are in the context and not individual lock surfaces
|
||||
// so all surfaces can share the same state.
|
||||
property string currentText: ""
|
||||
property bool unlockInProgress: false
|
||||
property bool showFailure: false
|
||||
|
||||
// Clear the failure text once the user starts typing.
|
||||
onCurrentTextChanged: showFailure = false;
|
||||
|
||||
function tryUnlock() {
|
||||
if (currentText === "") return;
|
||||
|
||||
root.unlockInProgress = true;
|
||||
pam.start();
|
||||
}
|
||||
|
||||
PamContext {
|
||||
id: pam
|
||||
|
||||
// Its best to have a custom pam config for quickshell, as the system one
|
||||
// might not be what your interface expects, and break in some way.
|
||||
// This particular example only supports passwords.
|
||||
configDirectory: "pam"
|
||||
config: "password.conf"
|
||||
|
||||
// pam_unix will ask for a response for the password prompt
|
||||
onPamMessage: {
|
||||
if (this.responseRequired) {
|
||||
this.respond(root.currentText);
|
||||
}
|
||||
}
|
||||
|
||||
// pam_unix won't send any important messages so all we need is the completion status.
|
||||
onCompleted: result => {
|
||||
if (result == PamResult.Success) {
|
||||
root.unlocked();
|
||||
} else {
|
||||
root.currentText = "";
|
||||
root.showFailure = true;
|
||||
}
|
||||
|
||||
root.unlockInProgress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
118
quickshell/lock/LockSurface.qml
Normal file
118
quickshell/lock/LockSurface.qml
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls.Fusion
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Services.UPower
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
required property LockContext context
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: "/home/ceres/.local/state/niri/wallpaper"
|
||||
}
|
||||
|
||||
Label {
|
||||
id: clock
|
||||
property var date: new Date()
|
||||
|
||||
font.family: "Departure Mono"
|
||||
color: Colours.foreground
|
||||
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: parent.top
|
||||
topMargin: 100
|
||||
}
|
||||
|
||||
// The native font renderer tends to look nicer at large sizes.
|
||||
renderType: Text.NativeRendering
|
||||
font.pointSize: 80
|
||||
|
||||
// updates the clock every second
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
interval: 1000
|
||||
|
||||
onTriggered: clock.date = new Date();
|
||||
}
|
||||
|
||||
// updated when the date changes
|
||||
text: {
|
||||
const hours = this.date.getHours().toString().padStart(2, '0');
|
||||
const minutes = this.date.getMinutes().toString().padStart(2, '0');
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: parent.top
|
||||
topMargin: 250
|
||||
}
|
||||
|
||||
renderType: Text.NativeRendering
|
||||
font.pointSize: 30
|
||||
font.family: "Departure Mono"
|
||||
color: Colours.foreground
|
||||
|
||||
text: Math.floor(UPower.displayDevice.percentage * 100) + "% Battery"
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
// Uncommenting this will make the password entry invisible except on the active monitor.
|
||||
// visible: Window.active
|
||||
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
top: parent.verticalCenter
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
TextField {
|
||||
id: passwordBox
|
||||
|
||||
background: Rectangle {
|
||||
color: Colours.background
|
||||
opacity: 0.9
|
||||
border.width: 4
|
||||
border.color: Colours.colour2
|
||||
radius: 20
|
||||
}
|
||||
|
||||
implicitWidth: 400
|
||||
padding: 10
|
||||
color: Colours.foreground
|
||||
horizontalAlignment: TextInput.AlignHCenter
|
||||
|
||||
focus: true
|
||||
enabled: !root.context.unlockInProgress
|
||||
echoMode: TextInput.Password
|
||||
inputMethodHints: Qt.ImhSensitiveData
|
||||
|
||||
onTextChanged: root.context.currentText = this.text;
|
||||
|
||||
onAccepted: root.context.tryUnlock();
|
||||
|
||||
Connections {
|
||||
target: root.context
|
||||
|
||||
function onCurrentTextChanged() {
|
||||
passwordBox.text = root.context.currentText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: root.context.showFailure
|
||||
text: "Incorrect password"
|
||||
font.family: "Departure Mono"
|
||||
color: Colours.foreground
|
||||
}
|
||||
}
|
||||
}
|
||||
3
quickshell/lock/pam/password.conf
Normal file
3
quickshell/lock/pam/password.conf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
auth required pam_unix.so
|
||||
auth required pam_u2f.so cue authfile=/etc/u2f_mappings
|
||||
|
||||
31
quickshell/lock/shell.qml
Normal file
31
quickshell/lock/shell.qml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
|
||||
ShellRoot {
|
||||
// This stores all the information shared between the lock surfaces on each screen.
|
||||
LockContext {
|
||||
id: lockContext
|
||||
|
||||
onUnlocked: {
|
||||
// Unlock the screen before exiting, or the compositor will display a
|
||||
// fallback lock you can't interact with.
|
||||
lock.locked = false;
|
||||
|
||||
Qt.quit();
|
||||
}
|
||||
}
|
||||
|
||||
WlSessionLock {
|
||||
id: lock
|
||||
|
||||
// Lock the session immediately when quickshell starts.
|
||||
locked: true
|
||||
|
||||
WlSessionLockSurface {
|
||||
LockSurface {
|
||||
anchors.fill: parent
|
||||
context: lockContext
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue