1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

idle: add fade to lock option

fixes #694
fixes #805
This commit is contained in:
bbedward
2025-11-24 10:59:36 -05:00
parent 6c4a9bcfb8
commit ee03853901
9 changed files with 582 additions and 385 deletions

View File

@@ -243,6 +243,8 @@ Singleton {
property bool lockBeforeSuspend: false
property bool preventIdleForMedia: false
property bool loginctlLockIntegration: true
property bool fadeToLockEnabled: false
property int fadeToLockGracePeriod: 5
property string launchPrefix: ""
property var brightnessDevicePins: ({})
property var wifiNetworkPins: ({})

View File

@@ -145,6 +145,8 @@ var SPEC = {
lockBeforeSuspend: { def: false },
preventIdleForMedia: { def: false },
loginctlLockIntegration: { def: true },
fadeToLockEnabled: { def: false },
fadeToLockGracePeriod: { def: 5 },
launchPrefix: { def: "" },
brightnessDevicePins: { def: {} },
wifiNetworkPins: { def: {} },

View File

@@ -63,6 +63,46 @@ Item {
id: lock
}
Variants {
model: Quickshell.screens
delegate: Loader {
id: fadeWindowLoader
required property var modelData
active: SettingsData.fadeToLockEnabled
asynchronous: false
sourceComponent: FadeToLockWindow {
screen: fadeWindowLoader.modelData
onFadeCompleted: {
IdleService.lockRequested();
}
onFadeCancelled: {
console.log("Fade to lock cancelled by user on screen:", fadeWindowLoader.modelData.name);
}
}
Connections {
target: IdleService
enabled: fadeWindowLoader.item !== null
function onFadeToLockRequested() {
if (fadeWindowLoader.item) {
fadeWindowLoader.item.startFade();
}
}
function onCancelFadeToLock() {
if (fadeWindowLoader.item) {
fadeWindowLoader.item.cancelFade();
}
}
}
}
}
Repeater {
id: dankBarRepeater
model: ScriptModel {

View File

@@ -76,10 +76,10 @@ Item {
checked: SessionService.loginctlAvailable && SettingsData.loginctlLockIntegration
enabled: SessionService.loginctlAvailable
onToggled: checked => {
if (SessionService.loginctlAvailable) {
SettingsData.set("loginctlLockIntegration", checked)
}
}
if (SessionService.loginctlAvailable) {
SettingsData.set("loginctlLockIntegration", checked);
}
}
}
DankToggle {
@@ -160,6 +160,40 @@ Item {
onToggled: checked => SettingsData.set("preventIdleForMedia", checked)
}
DankToggle {
width: parent.width
text: I18n.tr("Fade to lock screen")
description: I18n.tr("Gradually fade the screen before locking with a configurable grace period")
checked: SettingsData.fadeToLockEnabled
onToggled: checked => SettingsData.set("fadeToLockEnabled", checked)
}
DankDropdown {
id: fadeGracePeriodDropdown
property var periodOptions: ["1 second", "2 seconds", "3 seconds", "4 seconds", "5 seconds", "10 seconds", "15 seconds", "20 seconds", "30 seconds"]
property var periodValues: [1, 2, 3, 4, 5, 10, 15, 20, 30]
width: parent.width
addHorizontalPadding: true
text: I18n.tr("Fade grace period")
options: periodOptions
visible: SettingsData.fadeToLockEnabled
enabled: SettingsData.fadeToLockEnabled
Component.onCompleted: {
const currentPeriod = SettingsData.fadeToLockGracePeriod;
const index = periodValues.indexOf(currentPeriod);
currentValue = index >= 0 ? periodOptions[index] : "5 seconds";
}
onValueChanged: value => {
const index = periodOptions.indexOf(value);
if (index >= 0) {
SettingsData.set("fadeToLockGracePeriod", periodValues[index]);
}
}
}
DankDropdown {
id: lockDropdown
property var timeoutOptions: ["Never", "1 minute", "2 minutes", "3 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes", "30 minutes", "1 hour", "1 hour 30 minutes", "2 hours", "3 hours"]
@@ -172,29 +206,29 @@ Item {
Connections {
target: powerCategory
function onCurrentIndexChanged() {
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acLockTimeout : SettingsData.batteryLockTimeout
const index = lockDropdown.timeoutValues.indexOf(currentTimeout)
lockDropdown.currentValue = index >= 0 ? lockDropdown.timeoutOptions[index] : "Never"
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acLockTimeout : SettingsData.batteryLockTimeout;
const index = lockDropdown.timeoutValues.indexOf(currentTimeout);
lockDropdown.currentValue = index >= 0 ? lockDropdown.timeoutOptions[index] : "Never";
}
}
Component.onCompleted: {
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acLockTimeout : SettingsData.batteryLockTimeout
const index = timeoutValues.indexOf(currentTimeout)
currentValue = index >= 0 ? timeoutOptions[index] : "Never"
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acLockTimeout : SettingsData.batteryLockTimeout;
const index = timeoutValues.indexOf(currentTimeout);
currentValue = index >= 0 ? timeoutOptions[index] : "Never";
}
onValueChanged: value => {
const index = timeoutOptions.indexOf(value)
if (index >= 0) {
const timeout = timeoutValues[index]
if (powerCategory.currentIndex === 0) {
SettingsData.set("acLockTimeout", timeout)
} else {
SettingsData.set("batteryLockTimeout", timeout)
}
}
}
const index = timeoutOptions.indexOf(value);
if (index >= 0) {
const timeout = timeoutValues[index];
if (powerCategory.currentIndex === 0) {
SettingsData.set("acLockTimeout", timeout);
} else {
SettingsData.set("batteryLockTimeout", timeout);
}
}
}
}
DankDropdown {
@@ -209,29 +243,29 @@ Item {
Connections {
target: powerCategory
function onCurrentIndexChanged() {
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acMonitorTimeout : SettingsData.batteryMonitorTimeout
const index = monitorDropdown.timeoutValues.indexOf(currentTimeout)
monitorDropdown.currentValue = index >= 0 ? monitorDropdown.timeoutOptions[index] : "Never"
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acMonitorTimeout : SettingsData.batteryMonitorTimeout;
const index = monitorDropdown.timeoutValues.indexOf(currentTimeout);
monitorDropdown.currentValue = index >= 0 ? monitorDropdown.timeoutOptions[index] : "Never";
}
}
Component.onCompleted: {
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acMonitorTimeout : SettingsData.batteryMonitorTimeout
const index = timeoutValues.indexOf(currentTimeout)
currentValue = index >= 0 ? timeoutOptions[index] : "Never"
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acMonitorTimeout : SettingsData.batteryMonitorTimeout;
const index = timeoutValues.indexOf(currentTimeout);
currentValue = index >= 0 ? timeoutOptions[index] : "Never";
}
onValueChanged: value => {
const index = timeoutOptions.indexOf(value)
if (index >= 0) {
const timeout = timeoutValues[index]
if (powerCategory.currentIndex === 0) {
SettingsData.set("acMonitorTimeout", timeout)
} else {
SettingsData.set("batteryMonitorTimeout", timeout)
}
}
}
const index = timeoutOptions.indexOf(value);
if (index >= 0) {
const timeout = timeoutValues[index];
if (powerCategory.currentIndex === 0) {
SettingsData.set("acMonitorTimeout", timeout);
} else {
SettingsData.set("batteryMonitorTimeout", timeout);
}
}
}
}
DankDropdown {
@@ -246,29 +280,29 @@ Item {
Connections {
target: powerCategory
function onCurrentIndexChanged() {
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acSuspendTimeout : SettingsData.batterySuspendTimeout
const index = suspendDropdown.timeoutValues.indexOf(currentTimeout)
suspendDropdown.currentValue = index >= 0 ? suspendDropdown.timeoutOptions[index] : "Never"
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acSuspendTimeout : SettingsData.batterySuspendTimeout;
const index = suspendDropdown.timeoutValues.indexOf(currentTimeout);
suspendDropdown.currentValue = index >= 0 ? suspendDropdown.timeoutOptions[index] : "Never";
}
}
Component.onCompleted: {
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acSuspendTimeout : SettingsData.batterySuspendTimeout
const index = timeoutValues.indexOf(currentTimeout)
currentValue = index >= 0 ? timeoutOptions[index] : "Never"
const currentTimeout = powerCategory.currentIndex === 0 ? SettingsData.acSuspendTimeout : SettingsData.batterySuspendTimeout;
const index = timeoutValues.indexOf(currentTimeout);
currentValue = index >= 0 ? timeoutOptions[index] : "Never";
}
onValueChanged: value => {
const index = timeoutOptions.indexOf(value)
if (index >= 0) {
const timeout = timeoutValues[index]
if (powerCategory.currentIndex === 0) {
SettingsData.set("acSuspendTimeout", timeout)
} else {
SettingsData.set("batterySuspendTimeout", timeout)
}
}
}
const index = timeoutOptions.indexOf(value);
if (index >= 0) {
const timeout = timeoutValues[index];
if (powerCategory.currentIndex === 0) {
SettingsData.set("acSuspendTimeout", timeout);
} else {
SettingsData.set("batterySuspendTimeout", timeout);
}
}
}
}
Column {
@@ -293,25 +327,25 @@ Item {
Connections {
target: powerCategory
function onCurrentIndexChanged() {
const behavior = powerCategory.currentIndex === 0 ? SettingsData.acSuspendBehavior : SettingsData.batterySuspendBehavior
suspendBehaviorSelector.currentIndex = behavior
const behavior = powerCategory.currentIndex === 0 ? SettingsData.acSuspendBehavior : SettingsData.batterySuspendBehavior;
suspendBehaviorSelector.currentIndex = behavior;
}
}
Component.onCompleted: {
const behavior = powerCategory.currentIndex === 0 ? SettingsData.acSuspendBehavior : SettingsData.batterySuspendBehavior
currentIndex = behavior
const behavior = powerCategory.currentIndex === 0 ? SettingsData.acSuspendBehavior : SettingsData.batterySuspendBehavior;
currentIndex = behavior;
}
onSelectionChanged: (index, selected) => {
if (selected) {
if (powerCategory.currentIndex === 0) {
SettingsData.set("acSuspendBehavior", index)
} else {
SettingsData.set("batterySuspendBehavior", index)
}
}
}
if (selected) {
if (powerCategory.currentIndex === 0) {
SettingsData.set("acSuspendBehavior", index);
} else {
SettingsData.set("batterySuspendBehavior", index);
}
}
}
}
}
@@ -384,17 +418,17 @@ Item {
property var actionValues: ["reboot", "logout", "poweroff", "lock", "suspend", "restart", "hibernate"]
Component.onCompleted: {
const currentAction = SettingsData.powerMenuDefaultAction || "logout"
const index = actionValues.indexOf(currentAction)
currentValue = index >= 0 ? options[index] : "Log Out"
const currentAction = SettingsData.powerMenuDefaultAction || "logout";
const index = actionValues.indexOf(currentAction);
currentValue = index >= 0 ? options[index] : "Log Out";
}
onValueChanged: value => {
const index = options.indexOf(value)
if (index >= 0) {
SettingsData.set("powerMenuDefaultAction", actionValues[index])
}
}
const index = options.indexOf(value);
if (index >= 0) {
SettingsData.set("powerMenuDefaultAction", actionValues[index]);
}
}
}
Column {
@@ -406,14 +440,14 @@ Item {
text: I18n.tr("Show Reboot")
checked: SettingsData.powerMenuActions.includes("reboot")
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("reboot")) {
actions.push("reboot")
} else if (!checked) {
actions = actions.filter(a => a !== "reboot")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("reboot")) {
actions.push("reboot");
} else if (!checked) {
actions = actions.filter(a => a !== "reboot");
}
SettingsData.set("powerMenuActions", actions);
}
}
DankToggle {
@@ -421,14 +455,14 @@ Item {
text: I18n.tr("Show Log Out")
checked: SettingsData.powerMenuActions.includes("logout")
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("logout")) {
actions.push("logout")
} else if (!checked) {
actions = actions.filter(a => a !== "logout")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("logout")) {
actions.push("logout");
} else if (!checked) {
actions = actions.filter(a => a !== "logout");
}
SettingsData.set("powerMenuActions", actions);
}
}
DankToggle {
@@ -436,14 +470,14 @@ Item {
text: I18n.tr("Show Power Off")
checked: SettingsData.powerMenuActions.includes("poweroff")
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("poweroff")) {
actions.push("poweroff")
} else if (!checked) {
actions = actions.filter(a => a !== "poweroff")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("poweroff")) {
actions.push("poweroff");
} else if (!checked) {
actions = actions.filter(a => a !== "poweroff");
}
SettingsData.set("powerMenuActions", actions);
}
}
DankToggle {
@@ -451,14 +485,14 @@ Item {
text: I18n.tr("Show Lock")
checked: SettingsData.powerMenuActions.includes("lock")
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("lock")) {
actions.push("lock")
} else if (!checked) {
actions = actions.filter(a => a !== "lock")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("lock")) {
actions.push("lock");
} else if (!checked) {
actions = actions.filter(a => a !== "lock");
}
SettingsData.set("powerMenuActions", actions);
}
}
DankToggle {
@@ -466,14 +500,14 @@ Item {
text: I18n.tr("Show Suspend")
checked: SettingsData.powerMenuActions.includes("suspend")
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("suspend")) {
actions.push("suspend")
} else if (!checked) {
actions = actions.filter(a => a !== "suspend")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("suspend")) {
actions.push("suspend");
} else if (!checked) {
actions = actions.filter(a => a !== "suspend");
}
SettingsData.set("powerMenuActions", actions);
}
}
DankToggle {
@@ -482,14 +516,14 @@ Item {
description: I18n.tr("Restart the DankMaterialShell")
checked: SettingsData.powerMenuActions.includes("restart")
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("restart")) {
actions.push("restart")
} else if (!checked) {
actions = actions.filter(a => a !== "restart")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("restart")) {
actions.push("restart");
} else if (!checked) {
actions = actions.filter(a => a !== "restart");
}
SettingsData.set("powerMenuActions", actions);
}
}
DankToggle {
@@ -499,14 +533,14 @@ Item {
checked: SettingsData.powerMenuActions.includes("hibernate")
visible: SessionService.hibernateSupported
onToggled: checked => {
let actions = [...SettingsData.powerMenuActions]
if (checked && !actions.includes("hibernate")) {
actions.push("hibernate")
} else if (!checked) {
actions = actions.filter(a => a !== "hibernate")
}
SettingsData.set("powerMenuActions", actions)
}
let actions = [...SettingsData.powerMenuActions];
if (checked && !actions.includes("hibernate")) {
actions.push("hibernate");
} else if (!checked) {
actions = actions.filter(a => a !== "hibernate");
}
SettingsData.set("powerMenuActions", actions);
}
}
}
}
@@ -612,12 +646,12 @@ Item {
Component.onCompleted: {
if (SettingsData.customPowerActionLock) {
text = SettingsData.customPowerActionLock
text = SettingsData.customPowerActionLock;
}
}
onTextEdited: {
SettingsData.set("customPowerActionLock", text.trim())
SettingsData.set("customPowerActionLock", text.trim());
}
}
}
@@ -644,12 +678,12 @@ Item {
Component.onCompleted: {
if (SettingsData.customPowerActionLogout) {
text = SettingsData.customPowerActionLogout
text = SettingsData.customPowerActionLogout;
}
}
onTextEdited: {
SettingsData.set("customPowerActionLogout", text.trim())
SettingsData.set("customPowerActionLogout", text.trim());
}
}
}
@@ -676,12 +710,12 @@ Item {
Component.onCompleted: {
if (SettingsData.customPowerActionSuspend) {
text = SettingsData.customPowerActionSuspend
text = SettingsData.customPowerActionSuspend;
}
}
onTextEdited: {
SettingsData.set("customPowerActionSuspend", text.trim())
SettingsData.set("customPowerActionSuspend", text.trim());
}
}
}
@@ -708,12 +742,12 @@ Item {
Component.onCompleted: {
if (SettingsData.customPowerActionHibernate) {
text = SettingsData.customPowerActionHibernate
text = SettingsData.customPowerActionHibernate;
}
}
onTextEdited: {
SettingsData.set("customPowerActionHibernate", text.trim())
SettingsData.set("customPowerActionHibernate", text.trim());
}
}
}
@@ -740,12 +774,12 @@ Item {
Component.onCompleted: {
if (SettingsData.customPowerActionReboot) {
text = SettingsData.customPowerActionReboot
text = SettingsData.customPowerActionReboot;
}
}
onTextEdited: {
SettingsData.set("customPowerActionReboot", text.trim())
SettingsData.set("customPowerActionReboot", text.trim());
}
}
}
@@ -772,12 +806,12 @@ Item {
Component.onCompleted: {
if (SettingsData.customPowerActionPowerOff) {
text = SettingsData.customPowerActionPowerOff
text = SettingsData.customPowerActionPowerOff;
}
}
onTextEdited: {
SettingsData.set("customPowerActionPowerOff", text.trim())
SettingsData.set("customPowerActionPowerOff", text.trim());
}
}
}

View File

@@ -0,0 +1,102 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Common
PanelWindow {
id: root
property bool active: false
signal fadeCompleted
signal fadeCancelled
visible: active
color: "transparent"
WlrLayershell.namespace: "dms:fade-to-lock"
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: active ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
anchors {
left: true
right: true
top: true
bottom: true
}
Rectangle {
id: fadeOverlay
anchors.fill: parent
color: "black"
opacity: 0
onOpacityChanged: {
if (opacity >= 0.99 && root.active) {
root.fadeCompleted();
}
}
}
SequentialAnimation {
id: fadeSeq
running: false
NumberAnimation {
target: fadeOverlay
property: "opacity"
from: 0.0
to: 1.0
duration: SettingsData.fadeToLockGracePeriod * 1000
easing.type: Easing.OutCubic
}
}
function startFade() {
if (!SettingsData.fadeToLockEnabled)
return;
active = true;
fadeOverlay.opacity = 0.0;
fadeSeq.stop();
fadeSeq.start();
}
function cancelFade() {
fadeSeq.stop();
fadeOverlay.opacity = 0.0;
active = false;
fadeCancelled();
}
MouseArea {
anchors.fill: parent
enabled: root.active
onClicked: root.cancelFade()
onPressed: root.cancelFade()
}
FocusScope {
anchors.fill: parent
focus: root.active
Keys.onPressed: event => {
root.cancelFade();
event.accepted = true;
}
}
Component.onCompleted: {
if (active) {
forceActiveFocus();
}
}
onActiveChanged: {
if (active) {
forceActiveFocus();
}
}
}

View File

@@ -15,23 +15,23 @@ Scope {
property bool processingExternalEvent: false
Component.onCompleted: {
IdleService.lockComponent = this
IdleService.lockComponent = this;
}
function lock() {
if (SettingsData.customPowerActionLock && SettingsData.customPowerActionLock.length > 0) {
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock])
return
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock]);
return;
}
if (!processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) {
DMSService.lockSession(response => {
if (response.error) {
console.warn("Lock: Failed to call loginctl.lock:", response.error)
shouldLock = true
console.warn("Lock: Failed to call loginctl.lock:", response.error);
shouldLock = true;
}
})
});
} else {
shouldLock = true
shouldLock = true;
}
}
@@ -39,32 +39,32 @@ Scope {
if (!processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) {
DMSService.unlockSession(response => {
if (response.error) {
console.warn("Lock: Failed to call loginctl.unlock:", response.error)
shouldLock = false
console.warn("Lock: Failed to call loginctl.unlock:", response.error);
shouldLock = false;
}
})
});
} else {
shouldLock = false
shouldLock = false;
}
}
function activate() {
lock()
lock();
}
Connections {
target: SessionService
function onSessionLocked() {
processingExternalEvent = true
shouldLock = true
processingExternalEvent = false
processingExternalEvent = true;
shouldLock = true;
processingExternalEvent = false;
}
function onSessionUnlocked() {
processingExternalEvent = true
shouldLock = false
processingExternalEvent = false
processingExternalEvent = true;
shouldLock = false;
processingExternalEvent = false;
}
}
@@ -72,7 +72,7 @@ Scope {
target: IdleService
function onLockRequested() {
lock()
lock();
}
}
@@ -93,11 +93,11 @@ Scope {
screenName: lockSurface.screen?.name ?? ""
isLocked: shouldLock
onUnlockRequested: {
root.unlock()
root.unlock();
}
onPasswordChanged: newPassword => {
root.sharedPasswordBuffer = newPassword
}
root.sharedPasswordBuffer = newPassword;
}
}
}
}
@@ -113,21 +113,21 @@ Scope {
if (!root.processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) {
DMSService.lockSession(response => {
if (response.error) {
console.warn("Lock: Failed to call loginctl.lock:", response.error)
root.shouldLock = true
console.warn("Lock: Failed to call loginctl.lock:", response.error);
root.shouldLock = true;
}
})
});
} else {
root.shouldLock = true
root.shouldLock = true;
}
}
function demo() {
demoWindow.showDemo()
demoWindow.showDemo();
}
function isLocked(): bool {
return sessionLock.locked
return sessionLock.locked;
}
}
}

View File

@@ -1,6 +1,5 @@
pragma ComponentBehavior: Bound
import QtCore
import QtQuick
import QtQuick.Effects
import QtQuick.Layouts
@@ -30,52 +29,60 @@ Item {
signal unlockRequested
function pickRandomFact() {
randomFact = Facts.getRandomFact()
randomFact = Facts.getRandomFact();
}
Component.onCompleted: {
if (demoMode) {
pickRandomFact()
pickRandomFact();
}
WeatherService.addRef()
UserInfoService.refreshUserInfo()
WeatherService.addRef();
UserInfoService.refreshUserInfo();
if (CompositorService.isHyprland) {
updateHyprlandLayout()
hyprlandLayoutUpdateTimer.start()
updateHyprlandLayout();
hyprlandLayoutUpdateTimer.start();
}
lockerReadyArmed = true
lockerReadyArmed = true;
}
onDemoModeChanged: {
if (demoMode) {
pickRandomFact()
pickRandomFact();
}
}
Component.onDestruction: {
WeatherService.removeRef()
WeatherService.removeRef();
if (CompositorService.isHyprland) {
hyprlandLayoutUpdateTimer.stop()
hyprlandLayoutUpdateTimer.stop();
}
}
function sendLockerReadyOnce() {
if (lockerReadySent) return;
if (root.unlocking) return;
if (lockerReadySent)
return;
if (root.unlocking)
return;
lockerReadySent = true;
if (SessionService.loginctlAvailable && DMSService.apiVersion >= 2) {
DMSService.sendRequest("loginctl.lockerReady", null, resp => {
if (resp?.error) console.warn("lockerReady failed:", resp.error)
else console.log("lockerReady sent (afterAnimating/afterRendering)");
if (resp?.error)
console.warn("lockerReady failed:", resp.error);
else
console.log("lockerReady sent (afterAnimating/afterRendering)");
});
}
}
function maybeSend() {
if (!lockerReadyArmed) return;
if (root.unlocking) return;
if (!root.visible || root.opacity <= 0) return;
if (!lockerReadyArmed)
return;
if (root.unlocking)
return;
if (!root.visible || root.opacity <= 0)
return;
Qt.callLater(() => {
if (root.visible && root.opacity > 0 && !root.unlocking)
sendLockerReadyOnce();
@@ -86,8 +93,12 @@ Item {
target: root.Window.window
enabled: target !== null
function onAfterAnimating() { maybeSend(); }
function onAfterRendering() { maybeSend(); }
function onAfterAnimating() {
maybeSend();
}
function onAfterRendering() {
maybeSend();
}
}
onVisibleChanged: maybeSend()
@@ -95,7 +106,7 @@ Item {
function updateHyprlandLayout() {
if (CompositorService.isHyprland) {
hyprlandLayoutProcess.running = true
hyprlandLayoutProcess.running = true;
}
}
@@ -106,27 +117,27 @@ Item {
stdout: StdioCollector {
onStreamFinished: {
try {
const data = JSON.parse(text)
const mainKeyboard = data.keyboards.find(kb => kb.main === true)
hyprlandKeyboard = mainKeyboard.name
const data = JSON.parse(text);
const mainKeyboard = data.keyboards.find(kb => kb.main === true);
hyprlandKeyboard = mainKeyboard.name;
if (mainKeyboard && mainKeyboard.active_keymap) {
const parts = mainKeyboard.active_keymap.split(" ")
const parts = mainKeyboard.active_keymap.split(" ");
if (parts.length > 0) {
hyprlandCurrentLayout = parts[0].substring(0, 2).toUpperCase()
hyprlandCurrentLayout = parts[0].substring(0, 2).toUpperCase();
} else {
hyprlandCurrentLayout = mainKeyboard.active_keymap.substring(0, 2).toUpperCase()
hyprlandCurrentLayout = mainKeyboard.active_keymap.substring(0, 2).toUpperCase();
}
} else {
hyprlandCurrentLayout = ""
hyprlandCurrentLayout = "";
}
if (mainKeyboard && mainKeyboard.layout_names) {
hyprlandLayoutCount = mainKeyboard.layout_names.length
hyprlandLayoutCount = mainKeyboard.layout_names.length;
} else {
hyprlandLayoutCount = 0
hyprlandLayoutCount = 0;
}
} catch (e) {
hyprlandCurrentLayout = ""
hyprlandLayoutCount = 0
hyprlandCurrentLayout = "";
hyprlandLayoutCount = 0;
}
}
}
@@ -143,8 +154,8 @@ Item {
Loader {
anchors.fill: parent
active: {
var currentWallpaper = SessionData.getMonitorWallpaper(screenName)
return !currentWallpaper || (currentWallpaper && currentWallpaper.startsWith("#"))
var currentWallpaper = SessionData.getMonitorWallpaper(screenName);
return !currentWallpaper || (currentWallpaper && currentWallpaper.startsWith("#"));
}
asynchronous: true
@@ -158,8 +169,8 @@ Item {
anchors.fill: parent
source: {
var currentWallpaper = SessionData.getMonitorWallpaper(screenName)
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? currentWallpaper : ""
var currentWallpaper = SessionData.getMonitorWallpaper(screenName);
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? currentWallpaper : "";
}
fillMode: Theme.getFillMode(SettingsData.wallpaperFillMode)
smooth: true
@@ -213,8 +224,8 @@ Item {
spacing: 0
property string fullTimeStr: {
const format = SettingsData.getEffectiveTimeFormat()
return systemClock.date.toLocaleTimeString(Qt.locale(), format)
const format = SettingsData.getEffectiveTimeFormat();
return systemClock.date.toLocaleTimeString(Qt.locale(), format);
}
property var timeParts: fullTimeStr.split(':')
property string hours: timeParts[0] || ""
@@ -222,8 +233,8 @@ Item {
property string secondsWithAmPm: timeParts.length > 2 ? timeParts[2] : ""
property string seconds: secondsWithAmPm.replace(/\s*(AM|PM|am|pm)$/i, '')
property string ampm: {
const match = fullTimeStr.match(/\s*(AM|PM|am|pm)$/i)
return match ? match[0].trim() : ""
const match = fullTimeStr.match(/\s*(AM|PM|am|pm)$/i);
return match ? match[0].trim() : "";
}
property bool hasSeconds: timeParts.length > 2
@@ -322,9 +333,9 @@ Item {
anchors.verticalCenterOffset: -25
text: {
if (SettingsData.lockDateFormat && SettingsData.lockDateFormat.length > 0) {
return systemClock.date.toLocaleDateString(Qt.locale(), SettingsData.lockDateFormat)
return systemClock.date.toLocaleDateString(Qt.locale(), SettingsData.lockDateFormat);
}
return systemClock.date.toLocaleDateString(Qt.locale(), Locale.LongFormat)
return systemClock.date.toLocaleDateString(Qt.locale(), Locale.LongFormat);
}
font.pixelSize: Theme.fontSizeXLarge
color: "white"
@@ -347,14 +358,14 @@ Item {
Layout.preferredHeight: 60
imageSource: {
if (PortalService.profileImage === "") {
return ""
return "";
}
if (PortalService.profileImage.startsWith("/")) {
return "file://" + PortalService.profileImage
return "file://" + PortalService.profileImage;
}
return PortalService.profileImage
return PortalService.profileImage;
}
fallbackIcon: "person"
}
@@ -414,20 +425,20 @@ Item {
anchors.fill: parent
anchors.leftMargin: lockIconContainer.width + Theme.spacingM * 2
anchors.rightMargin: {
let margin = Theme.spacingM
let margin = Theme.spacingM;
if (loadingSpinner.visible) {
margin += loadingSpinner.width
margin += loadingSpinner.width;
}
if (enterButton.visible) {
margin += enterButton.width + 2
margin += enterButton.width + 2;
}
if (virtualKeyboardButton.visible) {
margin += virtualKeyboardButton.width
margin += virtualKeyboardButton.width;
}
if (revealButton.visible) {
margin += revealButton.width
margin += revealButton.width;
}
return margin
return margin;
}
opacity: 0
focus: true
@@ -436,36 +447,36 @@ Item {
echoMode: parent.showPassword ? TextInput.Normal : TextInput.Password
onTextChanged: {
if (!demoMode) {
root.passwordBuffer = text
root.passwordBuffer = text;
}
}
onAccepted: {
if (!demoMode && !pam.passwd.active) {
console.log("Enter pressed, starting PAM authentication")
pam.passwd.start()
console.log("Enter pressed, starting PAM authentication");
pam.passwd.start();
}
}
Keys.onPressed: event => {
if (demoMode) {
return
}
if (demoMode) {
return;
}
if (pam.passwd.active) {
console.log("PAM is active, ignoring input")
event.accepted = true
return
}
}
if (pam.passwd.active) {
console.log("PAM is active, ignoring input");
event.accepted = true;
return;
}
}
Component.onCompleted: {
if (!demoMode) {
forceActiveFocus()
forceActiveFocus();
}
}
onVisibleChanged: {
if (visible && !demoMode) {
forceActiveFocus()
forceActiveFocus();
}
}
@@ -473,9 +484,9 @@ Item {
if (!activeFocus && !demoMode && visible && passwordField && !powerMenu.isVisible) {
Qt.callLater(() => {
if (passwordField && passwordField.forceActiveFocus) {
passwordField.forceActiveFocus()
passwordField.forceActiveFocus();
}
})
});
}
}
@@ -483,9 +494,9 @@ Item {
if (enabled && !demoMode && visible && passwordField && !powerMenu.isVisible) {
Qt.callLater(() => {
if (passwordField && passwordField.forceActiveFocus) {
passwordField.forceActiveFocus()
passwordField.forceActiveFocus();
}
})
});
}
}
}
@@ -506,15 +517,15 @@ Item {
anchors.verticalCenter: parent.verticalCenter
text: {
if (demoMode) {
return ""
return "";
}
if (root.unlocking) {
return "Unlocking..."
return "Unlocking...";
}
if (pam.passwd.active) {
return "Authenticating..."
return "Authenticating...";
}
return "Password..."
return "Password...";
}
color: root.unlocking ? Theme.primary : (pam.passwd.active ? Theme.primary : Theme.outline)
font.pixelSize: Theme.fontSizeMedium
@@ -543,12 +554,12 @@ Item {
anchors.verticalCenter: parent.verticalCenter
text: {
if (demoMode) {
return "••••••••"
return "••••••••";
}
if (parent.showPassword) {
return root.passwordBuffer
return root.passwordBuffer;
}
return "•".repeat(root.passwordBuffer.length)
return "•".repeat(root.passwordBuffer.length);
}
color: Theme.surfaceText
font.pixelSize: parent.showPassword ? Theme.fontSizeMedium : Theme.fontSizeLarge
@@ -589,9 +600,9 @@ Item {
enabled: visible
onClicked: {
if (keyboardController.isKeyboardActive) {
keyboardController.hide()
keyboardController.hide();
} else {
keyboardController.show()
keyboardController.show();
}
}
}
@@ -690,8 +701,8 @@ Item {
enabled: !demoMode
onClicked: {
if (!demoMode) {
console.log("Enter button clicked, starting PAM authentication")
pam.passwd.start()
console.log("Enter button clicked, starting PAM authentication");
pam.passwd.start();
}
}
@@ -717,15 +728,15 @@ Item {
Layout.preferredHeight: 20
text: {
if (root.pamState === "error") {
return "Authentication error - try again"
return "Authentication error - try again";
}
if (root.pamState === "max") {
return "Too many attempts - locked out"
return "Too many attempts - locked out";
}
if (root.pamState === "fail") {
return "Incorrect password - try again"
return "Incorrect password - try again";
}
return ""
return "";
}
color: Theme.error
font.pixelSize: Theme.fontSizeSmall
@@ -793,11 +804,11 @@ Item {
anchors.verticalCenter: parent.verticalCenter
visible: {
if (CompositorService.isNiri) {
return NiriService.keyboardLayoutNames.length > 1
return NiriService.keyboardLayoutNames.length > 1;
} else if (CompositorService.isHyprland) {
return hyprlandLayoutCount > 1
return hyprlandLayoutCount > 1;
}
return false
return false;
}
Row {
@@ -823,17 +834,18 @@ Item {
StyledText {
text: {
if (CompositorService.isNiri) {
const layout = NiriService.getCurrentKeyboardLayoutName()
if (!layout) return ""
const parts = layout.split(" ")
const layout = NiriService.getCurrentKeyboardLayoutName();
if (!layout)
return "";
const parts = layout.split(" ");
if (parts.length > 0) {
return parts[0].substring(0, 2).toUpperCase()
return parts[0].substring(0, 2).toUpperCase();
}
return layout.substring(0, 2).toUpperCase()
return layout.substring(0, 2).toUpperCase();
} else if (CompositorService.isHyprland) {
return hyprlandCurrentLayout
return hyprlandCurrentLayout;
}
return ""
return "";
}
font.pixelSize: Theme.fontSizeMedium
font.weight: Font.Light
@@ -851,15 +863,10 @@ Item {
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
if (CompositorService.isNiri) {
NiriService.cycleKeyboardLayout()
NiriService.cycleKeyboardLayout();
} else if (CompositorService.isHyprland) {
Quickshell.execDetached([
"hyprctl",
"switchxkblayout",
hyprlandKeyboard,
"next"
])
updateHyprlandLayout()
Quickshell.execDetached(["hyprctl", "switchxkblayout", hyprlandKeyboard, "next"]);
updateHyprlandLayout();
}
}
}
@@ -898,7 +905,7 @@ Item {
interval: 256
repeat: true
onTriggered: {
CavaService.values = [Math.random() * 40 + 10, Math.random() * 60 + 20, Math.random() * 50 + 15, Math.random() * 35 + 20, Math.random() * 45 + 15, Math.random() * 55 + 25]
CavaService.values = [Math.random() * 40 + 10, Math.random() * 60 + 20, Math.random() * 50 + 15, Math.random() * 35 + 20, Math.random() * 45 + 15, Math.random() * 55 + 25];
}
}
@@ -914,13 +921,13 @@ Item {
width: 2
height: {
if (MprisController.activePlayer?.playbackState === MprisPlaybackState.Playing && CavaService.values.length > index) {
const rawLevel = CavaService.values[index] || 0
const scaledLevel = Math.sqrt(Math.min(Math.max(rawLevel, 0), 100) / 100) * 100
const maxHeight = Theme.iconSize - 2
const minHeight = 3
return minHeight + (scaledLevel / 100) * (maxHeight - minHeight)
const rawLevel = CavaService.values[index] || 0;
const scaledLevel = Math.sqrt(Math.min(Math.max(rawLevel, 0), 100) / 100) * 100;
const maxHeight = Theme.iconSize - 2;
const minHeight = 3;
return minHeight + (scaledLevel / 100) * (maxHeight - minHeight);
}
return 3
return 3;
}
radius: 1.5
color: "white"
@@ -940,11 +947,12 @@ Item {
StyledText {
text: {
const player = MprisController.activePlayer
if (!player?.trackTitle) return ""
const title = player.trackTitle
const artist = player.trackArtist || ""
return artist ? title + " • " + artist : title
const player = MprisController.activePlayer;
if (!player?.trackTitle)
return "";
const title = player.trackTitle;
const artist = player.trackArtist || "";
return artist ? title + " • " + artist : title;
}
font.pixelSize: Theme.fontSizeLarge
color: "white"
@@ -1099,15 +1107,15 @@ Item {
DankIcon {
name: {
if (!AudioService.sink?.audio) {
return "volume_up"
return "volume_up";
}
if (AudioService.sink.audio.muted || AudioService.sink.audio.volume === 0) {
return "volume_off"
return "volume_off";
}
if (AudioService.sink.audio.volume * 100 < 33) {
return "volume_down"
return "volume_down";
}
return "volume_up"
return "volume_up";
}
size: Theme.iconSize - 2
color: (AudioService.sink && AudioService.sink.audio && (AudioService.sink.audio.muted || AudioService.sink.audio.volume === 0)) ? Qt.rgba(255, 255, 255, 0.5) : "white"
@@ -1133,95 +1141,95 @@ Item {
name: {
if (BatteryService.isCharging) {
if (BatteryService.batteryLevel >= 90) {
return "battery_charging_full"
return "battery_charging_full";
}
if (BatteryService.batteryLevel >= 80) {
return "battery_charging_90"
return "battery_charging_90";
}
if (BatteryService.batteryLevel >= 60) {
return "battery_charging_80"
return "battery_charging_80";
}
if (BatteryService.batteryLevel >= 50) {
return "battery_charging_60"
return "battery_charging_60";
}
if (BatteryService.batteryLevel >= 30) {
return "battery_charging_50"
return "battery_charging_50";
}
if (BatteryService.batteryLevel >= 20) {
return "battery_charging_30"
return "battery_charging_30";
}
return "battery_charging_20"
return "battery_charging_20";
}
if (BatteryService.isPluggedIn) {
if (BatteryService.batteryLevel >= 90) {
return "battery_charging_full"
return "battery_charging_full";
}
if (BatteryService.batteryLevel >= 80) {
return "battery_charging_90"
return "battery_charging_90";
}
if (BatteryService.batteryLevel >= 60) {
return "battery_charging_80"
return "battery_charging_80";
}
if (BatteryService.batteryLevel >= 50) {
return "battery_charging_60"
return "battery_charging_60";
}
if (BatteryService.batteryLevel >= 30) {
return "battery_charging_50"
return "battery_charging_50";
}
if (BatteryService.batteryLevel >= 20) {
return "battery_charging_30"
return "battery_charging_30";
}
return "battery_charging_20"
return "battery_charging_20";
}
if (BatteryService.batteryLevel >= 95) {
return "battery_full"
return "battery_full";
}
if (BatteryService.batteryLevel >= 85) {
return "battery_6_bar"
return "battery_6_bar";
}
if (BatteryService.batteryLevel >= 70) {
return "battery_5_bar"
return "battery_5_bar";
}
if (BatteryService.batteryLevel >= 55) {
return "battery_4_bar"
return "battery_4_bar";
}
if (BatteryService.batteryLevel >= 40) {
return "battery_3_bar"
return "battery_3_bar";
}
if (BatteryService.batteryLevel >= 25) {
return "battery_2_bar"
return "battery_2_bar";
}
return "battery_1_bar"
return "battery_1_bar";
}
size: Theme.iconSize
color: {
if (BatteryService.isLowBattery && !BatteryService.isCharging) {
return Theme.error
return Theme.error;
}
if (BatteryService.isCharging || BatteryService.isPluggedIn) {
return Theme.primary
return Theme.primary;
}
return "white"
return "white";
}
anchors.verticalCenter: parent.verticalCenter
}
@@ -1246,9 +1254,9 @@ Item {
buttonSize: 40
onClicked: {
if (demoMode) {
console.log("Demo: Power Menu")
console.log("Demo: Power Menu");
} else {
powerMenu.show()
powerMenu.show();
}
}
}
@@ -1272,18 +1280,18 @@ Item {
id: pam
lockSecured: !demoMode
onUnlockRequested: {
root.unlocking = true
lockerReadyArmed = false
passwordField.text = ""
root.passwordBuffer = ""
root.unlockRequested()
root.unlocking = true;
lockerReadyArmed = false;
passwordField.text = "";
root.passwordBuffer = "";
root.unlockRequested();
}
onStateChanged: {
root.pamState = state
root.pamState = state;
if (state !== "") {
placeholderDelay.restart()
passwordField.text = ""
root.passwordBuffer = ""
placeholderDelay.restart();
passwordField.text = "";
root.passwordBuffer = "";
}
}
}
@@ -1312,7 +1320,7 @@ Item {
showLogout: true
onClosed: {
if (!demoMode && passwordField && passwordField.forceActiveFocus) {
Qt.callLater(() => passwordField.forceActiveFocus())
Qt.callLater(() => passwordField.forceActiveFocus());
}
}
}

View File

@@ -1,9 +1,7 @@
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Common
Rectangle {
id: root
@@ -14,7 +12,7 @@ Rectangle {
required property bool isLocked
signal passwordChanged(string newPassword)
signal unlockRequested()
signal unlockRequested
color: "transparent"
@@ -28,14 +26,14 @@ Rectangle {
onUnlockRequested: root.unlockRequested()
onPasswordBufferChanged: {
if (root.sharedPasswordBuffer !== passwordBuffer) {
root.passwordChanged(passwordBuffer)
root.passwordChanged(passwordBuffer);
}
}
}
onIsLockedChanged: {
if (!isLocked) {
lockContent.unlocking = false
lockContent.unlocking = false;
}
}
}

View File

@@ -4,26 +4,24 @@ pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import Quickshell.Services.Mpris
import qs.Common
import qs.Services
Singleton {
id: root
readonly property bool idleMonitorAvailable: {
try {
return typeof IdleMonitor !== "undefined"
return typeof IdleMonitor !== "undefined";
} catch (e) {
return false
return false;
}
}
readonly property bool idleInhibitorAvailable: {
try {
return typeof IdleInhibitor !== "undefined"
return typeof IdleInhibitor !== "undefined";
} catch (e) {
return false
return false;
}
}
@@ -44,32 +42,37 @@ Singleton {
onSuspendTimeoutChanged: _rearmIdleMonitors()
function _rearmIdleMonitors() {
_enableGate = false
Qt.callLater(() => { _enableGate = true })
_enableGate = false;
Qt.callLater(() => {
_enableGate = true;
});
}
signal lockRequested()
signal requestMonitorOff()
signal requestMonitorOn()
signal requestSuspend()
signal lockRequested
signal fadeToLockRequested
signal cancelFadeToLock
signal requestMonitorOff
signal requestMonitorOn
signal requestSuspend
property var monitorOffMonitor: null
property var lockMonitor: null
property var suspendMonitor: null
property var mediaInhibitor: null
property var lockComponent: null
function wake() {
requestMonitorOn()
requestMonitorOn();
}
function createMediaInhibitor() {
if (!idleInhibitorAvailable) {
return
return;
}
if (mediaInhibitor) {
mediaInhibitor.destroy()
mediaInhibitor = null
mediaInhibitor.destroy();
mediaInhibitor = null;
}
const inhibitorString = `
@@ -79,23 +82,23 @@ Singleton {
IdleInhibitor {
active: false
}
`
`;
mediaInhibitor = Qt.createQmlObject(inhibitorString, root, "IdleService.MediaInhibitor")
mediaInhibitor.active = Qt.binding(() => root.mediaPlaying)
mediaInhibitor = Qt.createQmlObject(inhibitorString, root, "IdleService.MediaInhibitor");
mediaInhibitor.active = Qt.binding(() => root.mediaPlaying);
}
function destroyMediaInhibitor() {
if (mediaInhibitor) {
mediaInhibitor.destroy()
mediaInhibitor = null
mediaInhibitor.destroy();
mediaInhibitor = null;
}
}
function createIdleMonitors() {
if (!idleMonitorAvailable) {
console.info("IdleService: IdleMonitor not available, skipping creation")
return
console.info("IdleService: IdleMonitor not available, skipping creation");
return;
}
try {
@@ -108,60 +111,68 @@ Singleton {
respectInhibitors: true
timeout: 0
}
`
`;
monitorOffMonitor = Qt.createQmlObject(qmlString, root, "IdleService.MonitorOffMonitor")
monitorOffMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.monitorTimeout > 0)
monitorOffMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors)
monitorOffMonitor.timeout = Qt.binding(() => root.monitorTimeout)
monitorOffMonitor.isIdleChanged.connect(function() {
monitorOffMonitor = Qt.createQmlObject(qmlString, root, "IdleService.MonitorOffMonitor");
monitorOffMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.monitorTimeout > 0);
monitorOffMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors);
monitorOffMonitor.timeout = Qt.binding(() => root.monitorTimeout);
monitorOffMonitor.isIdleChanged.connect(function () {
if (monitorOffMonitor.isIdle) {
root.requestMonitorOff()
root.requestMonitorOff();
} else {
root.requestMonitorOn()
root.requestMonitorOn();
}
})
});
lockMonitor = Qt.createQmlObject(qmlString, root, "IdleService.LockMonitor")
lockMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.lockTimeout > 0)
lockMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors)
lockMonitor.timeout = Qt.binding(() => root.lockTimeout)
lockMonitor.isIdleChanged.connect(function() {
lockMonitor = Qt.createQmlObject(qmlString, root, "IdleService.LockMonitor");
lockMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.lockTimeout > 0);
lockMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors);
lockMonitor.timeout = Qt.binding(() => root.lockTimeout);
lockMonitor.isIdleChanged.connect(function () {
if (lockMonitor.isIdle) {
root.lockRequested()
if (SettingsData.fadeToLockEnabled) {
root.fadeToLockRequested();
} else {
root.lockRequested();
}
} else {
if (SettingsData.fadeToLockEnabled) {
root.cancelFadeToLock();
}
}
})
});
suspendMonitor = Qt.createQmlObject(qmlString, root, "IdleService.SuspendMonitor")
suspendMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.suspendTimeout > 0)
suspendMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors)
suspendMonitor.timeout = Qt.binding(() => root.suspendTimeout)
suspendMonitor.isIdleChanged.connect(function() {
suspendMonitor = Qt.createQmlObject(qmlString, root, "IdleService.SuspendMonitor");
suspendMonitor.enabled = Qt.binding(() => root._enableGate && root.enabled && root.idleMonitorAvailable && root.suspendTimeout > 0);
suspendMonitor.respectInhibitors = Qt.binding(() => root.respectInhibitors);
suspendMonitor.timeout = Qt.binding(() => root.suspendTimeout);
suspendMonitor.isIdleChanged.connect(function () {
if (suspendMonitor.isIdle) {
root.requestSuspend()
root.requestSuspend();
}
})
});
if (SettingsData.preventIdleForMedia) {
createMediaInhibitor()
createMediaInhibitor();
}
} catch (e) {
console.warn("IdleService: Error creating IdleMonitors:", e)
console.warn("IdleService: Error creating IdleMonitors:", e);
}
}
Connections {
target: root
function onRequestMonitorOff() {
CompositorService.powerOffMonitors()
CompositorService.powerOffMonitors();
}
function onRequestMonitorOn() {
CompositorService.powerOnMonitors()
CompositorService.powerOnMonitors();
}
function onRequestSuspend() {
SessionService.suspendWithBehavior(root.suspendBehavior)
SessionService.suspendWithBehavior(root.suspendBehavior);
}
}
@@ -169,7 +180,7 @@ Singleton {
target: SessionService
function onPrepareForSleep() {
if (SettingsData.lockBeforeSuspend) {
root.lockRequested()
root.lockRequested();
}
}
}
@@ -178,19 +189,19 @@ Singleton {
target: SettingsData
function onPreventIdleForMediaChanged() {
if (SettingsData.preventIdleForMedia) {
createMediaInhibitor()
createMediaInhibitor();
} else {
destroyMediaInhibitor()
destroyMediaInhibitor();
}
}
}
Component.onCompleted: {
if (!idleMonitorAvailable) {
console.warn("IdleService: IdleMonitor not available - power management disabled. This requires a newer version of Quickshell.")
console.warn("IdleService: IdleMonitor not available - power management disabled. This requires a newer version of Quickshell.");
} else {
console.info("IdleService: Initialized with idle monitoring support")
createIdleMonitors()
console.info("IdleService: Initialized with idle monitoring support");
createIdleMonitors();
}
}
}
}