136 lines
4.1 KiB
QML
136 lines
4.1 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Wayland
|
|
import QtMultimedia
|
|
import "./shim"
|
|
|
|
ShellRoot {
|
|
id: shellRoot
|
|
|
|
property string baseDir: "/home/kokopi/.local/share/quickshell-lockscreen"
|
|
property string activeTheme: Quickshell.env("QS_THEME") || "nier-automata"
|
|
property string themePath: Quickshell.env("QS_THEME_PATH") || (baseDir + "/themes_link/" + activeTheme)
|
|
property string readyFile: Quickshell.env("QYLOCK_READY_FILE") || ""
|
|
property bool readySent: false
|
|
|
|
readonly property var sddm: sddmShim.sddm
|
|
readonly property var config: sddmShim.config
|
|
readonly property var userModel: sddmShim.userModel
|
|
readonly property var sessionModel: sddmShim.sessionModel
|
|
readonly property bool isWayland: Quickshell.env("XDG_SESSION_TYPE") === "wayland"
|
|
property bool authenticated: false
|
|
property bool sessionLocked: true
|
|
property bool isTesting: Quickshell.env("QS_TESTING") === "1"
|
|
|
|
function signalReady() {
|
|
if (readySent || readyFile === "")
|
|
return
|
|
|
|
readySent = true
|
|
Quickshell.execDetached([
|
|
"sh", "-c",
|
|
"umask 077; : > \"$1\"",
|
|
"sh", readyFile
|
|
])
|
|
}
|
|
|
|
SddmShim {
|
|
id: sddmShim
|
|
themePath: shellRoot.themePath
|
|
}
|
|
|
|
Connections {
|
|
target: sddmShim.sddm
|
|
function onLoginSucceeded() {
|
|
shellRoot.authenticated = true
|
|
shellRoot.sessionLocked = false
|
|
|
|
if (Quickshell.env("XDG_CURRENT_DESKTOP") === "Hyprland" || Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") !== "") {
|
|
Quickshell.execDetached(["hyprctl", "keyword", "misc:allow_session_lock_restore", "1"]);
|
|
}
|
|
Quickshell.execDetached(["loginctl", "unlock-session"]);
|
|
quitTimer.start()
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: quitTimer
|
|
interval: 1500
|
|
onTriggered: Qt.quit()
|
|
}
|
|
|
|
Component {
|
|
id: themeComponent
|
|
Loader {
|
|
anchors.fill: parent
|
|
source: "file://" + shellRoot.themePath + "/Main.qml"
|
|
|
|
onLoaded: item.forceActiveFocus()
|
|
onStatusChanged: {
|
|
if (status === Loader.Error) {
|
|
console.error("FAILED to load theme:", source)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: waylandLoader
|
|
active: shellRoot.isWayland
|
|
sourceComponent: Component {
|
|
WlSessionLock {
|
|
id: lock
|
|
locked: shellRoot.sessionLocked
|
|
|
|
onSecureStateChanged: {
|
|
if (secure)
|
|
shellRoot.signalReady()
|
|
}
|
|
|
|
surface: Component {
|
|
WlSessionLockSurface {
|
|
color: "black"
|
|
Loader {
|
|
anchors.fill: parent
|
|
sourceComponent: themeComponent
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Loader {
|
|
id: x11Loader
|
|
active: !shellRoot.isWayland
|
|
sourceComponent: Component {
|
|
Variants {
|
|
model: Quickshell.screens
|
|
delegate: Window {
|
|
id: window
|
|
required property var modelData
|
|
screen: modelData
|
|
width: isTesting ? 1280 : screen.width
|
|
height: isTesting ? 720 : screen.height
|
|
visible: shellRoot.sessionLocked
|
|
visibility: isTesting ? Window.Windowed : Window.FullScreen
|
|
|
|
Component.onCompleted: shellRoot.signalReady()
|
|
|
|
onClosing: (close) => {
|
|
close.accepted = shellRoot.authenticated || shellRoot.isTesting;
|
|
}
|
|
|
|
flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.MaximizeUsingFullscreenGeometryHint
|
|
color: "black"
|
|
|
|
Loader {
|
|
anchors.fill: parent
|
|
sourceComponent: themeComponent
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|