mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
@@ -278,6 +278,8 @@ Singleton {
|
|||||||
property bool loginctlLockIntegration: true
|
property bool loginctlLockIntegration: true
|
||||||
property bool fadeToLockEnabled: false
|
property bool fadeToLockEnabled: false
|
||||||
property int fadeToLockGracePeriod: 5
|
property int fadeToLockGracePeriod: 5
|
||||||
|
property bool fadeToDpmsEnabled: false
|
||||||
|
property int fadeToDpmsGracePeriod: 5
|
||||||
property string launchPrefix: ""
|
property string launchPrefix: ""
|
||||||
property var brightnessDevicePins: ({})
|
property var brightnessDevicePins: ({})
|
||||||
property var wifiNetworkPins: ({})
|
property var wifiNetworkPins: ({})
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ var SPEC = {
|
|||||||
loginctlLockIntegration: { def: true },
|
loginctlLockIntegration: { def: true },
|
||||||
fadeToLockEnabled: { def: false },
|
fadeToLockEnabled: { def: false },
|
||||||
fadeToLockGracePeriod: { def: 5 },
|
fadeToLockGracePeriod: { def: 5 },
|
||||||
|
fadeToDpmsEnabled: { def: false },
|
||||||
|
fadeToDpmsGracePeriod: { def: 5 },
|
||||||
launchPrefix: { def: "" },
|
launchPrefix: { def: "" },
|
||||||
brightnessDevicePins: { def: {} },
|
brightnessDevicePins: { def: {} },
|
||||||
wifiNetworkPins: { def: {} },
|
wifiNetworkPins: { def: {} },
|
||||||
|
|||||||
@@ -104,6 +104,46 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variants {
|
||||||
|
model: Quickshell.screens
|
||||||
|
|
||||||
|
delegate: Loader {
|
||||||
|
id: fadeDpmsWindowLoader
|
||||||
|
required property var modelData
|
||||||
|
active: SettingsData.fadeToDpmsEnabled
|
||||||
|
asynchronous: false
|
||||||
|
|
||||||
|
sourceComponent: FadeToDpmsWindow {
|
||||||
|
screen: fadeDpmsWindowLoader.modelData
|
||||||
|
|
||||||
|
onFadeCompleted: {
|
||||||
|
IdleService.requestMonitorOff();
|
||||||
|
}
|
||||||
|
|
||||||
|
onFadeCancelled: {
|
||||||
|
console.log("Fade to DPMS cancelled by user on screen:", fadeDpmsWindowLoader.modelData.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: IdleService
|
||||||
|
enabled: fadeDpmsWindowLoader.item !== null
|
||||||
|
|
||||||
|
function onFadeToDpmsRequested() {
|
||||||
|
if (fadeDpmsWindowLoader.item) {
|
||||||
|
fadeDpmsWindowLoader.item.startFade();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancelFadeToDpms() {
|
||||||
|
if (fadeDpmsWindowLoader.item) {
|
||||||
|
fadeDpmsWindowLoader.item.cancelFade();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: dankBarRepeater
|
id: dankBarRepeater
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
|
|||||||
102
quickshell/Modules/Lock/FadeToDpmsWindow.qml
Normal file
102
quickshell/Modules/Lock/FadeToDpmsWindow.qml
Normal 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-dpms"
|
||||||
|
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.fadeToDpmsGracePeriod * 1000
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startFade() {
|
||||||
|
if (!SettingsData.fadeToDpmsEnabled)
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,15 +23,12 @@ Scope {
|
|||||||
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock]);
|
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLock]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
shouldLock = true;
|
||||||
if (!processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) {
|
if (!processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) {
|
||||||
DMSService.lockSession(response => {
|
DMSService.lockSession(response => {
|
||||||
if (response.error) {
|
if (response.error)
|
||||||
console.warn("Lock: Failed to call loginctl.lock:", response.error);
|
console.warn("Lock: loginctl.lock failed:", response.error);
|
||||||
shouldLock = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
shouldLock = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +78,11 @@ Scope {
|
|||||||
|
|
||||||
locked: shouldLock
|
locked: shouldLock
|
||||||
|
|
||||||
|
onLockedChanged: {
|
||||||
|
if (locked)
|
||||||
|
dpmsReapplyTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
WlSessionLockSurface {
|
WlSessionLockSurface {
|
||||||
id: lockSurface
|
id: lockSurface
|
||||||
|
|
||||||
@@ -120,15 +122,12 @@ Scope {
|
|||||||
target: "lock"
|
target: "lock"
|
||||||
|
|
||||||
function lock() {
|
function lock() {
|
||||||
if (!root.processingExternalEvent && SettingsData.loginctlLockIntegration && DMSService.isConnected) {
|
root.shouldLock = true;
|
||||||
|
if (SettingsData.loginctlLockIntegration && DMSService.isConnected) {
|
||||||
DMSService.lockSession(response => {
|
DMSService.lockSession(response => {
|
||||||
if (response.error) {
|
if (response.error)
|
||||||
console.warn("Lock: Failed to call loginctl.lock:", response.error);
|
console.warn("Lock: loginctl.lock failed:", response.error);
|
||||||
root.shouldLock = true;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
root.shouldLock = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,4 +139,11 @@ Scope {
|
|||||||
return sessionLock.locked;
|
return sessionLock.locked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: dpmsReapplyTimer
|
||||||
|
interval: 100
|
||||||
|
repeat: false
|
||||||
|
onTriggered: IdleService.reapplyDpmsIfNeeded()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,15 @@ Item {
|
|||||||
onToggled: checked => SettingsData.set("fadeToLockEnabled", checked)
|
onToggled: checked => SettingsData.set("fadeToLockEnabled", checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsToggleRow {
|
||||||
|
settingKey: "fadeToDpmsEnabled"
|
||||||
|
tags: ["fade", "dpms", "monitor", "screen", "idle", "grace period"]
|
||||||
|
text: I18n.tr("Fade to monitor off")
|
||||||
|
description: I18n.tr("Gradually fade the screen before turning off monitors with a configurable grace period")
|
||||||
|
checked: SettingsData.fadeToDpmsEnabled
|
||||||
|
onToggled: checked => SettingsData.set("fadeToDpmsEnabled", checked)
|
||||||
|
}
|
||||||
|
|
||||||
SettingsToggleRow {
|
SettingsToggleRow {
|
||||||
settingKey: "lockBeforeSuspend"
|
settingKey: "lockBeforeSuspend"
|
||||||
tags: ["lock", "suspend", "sleep", "security"]
|
tags: ["lock", "suspend", "sleep", "security"]
|
||||||
@@ -89,7 +98,7 @@ Item {
|
|||||||
property var periodOptions: ["1 second", "2 seconds", "3 seconds", "4 seconds", "5 seconds", "10 seconds", "15 seconds", "20 seconds", "30 seconds"]
|
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]
|
property var periodValues: [1, 2, 3, 4, 5, 10, 15, 20, 30]
|
||||||
|
|
||||||
text: I18n.tr("Fade grace period")
|
text: I18n.tr("Lock fade grace period")
|
||||||
options: periodOptions
|
options: periodOptions
|
||||||
visible: SettingsData.fadeToLockEnabled
|
visible: SettingsData.fadeToLockEnabled
|
||||||
enabled: SettingsData.fadeToLockEnabled
|
enabled: SettingsData.fadeToLockEnabled
|
||||||
@@ -107,6 +116,32 @@ Item {
|
|||||||
SettingsData.set("fadeToLockGracePeriod", periodValues[index]);
|
SettingsData.set("fadeToLockGracePeriod", periodValues[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsDropdownRow {
|
||||||
|
id: fadeDpmsGracePeriodDropdown
|
||||||
|
settingKey: "fadeToDpmsGracePeriod"
|
||||||
|
tags: ["fade", "grace", "period", "timeout", "dpms", "monitor"]
|
||||||
|
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]
|
||||||
|
|
||||||
|
text: I18n.tr("Monitor fade grace period")
|
||||||
|
options: periodOptions
|
||||||
|
visible: SettingsData.fadeToDpmsEnabled
|
||||||
|
enabled: SettingsData.fadeToDpmsEnabled
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
const currentPeriod = SettingsData.fadeToDpmsGracePeriod;
|
||||||
|
const index = periodValues.indexOf(currentPeriod);
|
||||||
|
currentValue = index >= 0 ? periodOptions[index] : "5 seconds";
|
||||||
|
}
|
||||||
|
|
||||||
|
onValueChanged: value => {
|
||||||
|
const index = periodOptions.indexOf(value);
|
||||||
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
SettingsData.set("fadeToDpmsGracePeriod", periodValues[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
SettingsDropdownRow {
|
SettingsDropdownRow {
|
||||||
id: powerProfileDropdown
|
id: powerProfileDropdown
|
||||||
settingKey: "powerProfile"
|
settingKey: "powerProfile"
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ Singleton {
|
|||||||
signal lockRequested
|
signal lockRequested
|
||||||
signal fadeToLockRequested
|
signal fadeToLockRequested
|
||||||
signal cancelFadeToLock
|
signal cancelFadeToLock
|
||||||
|
signal fadeToDpmsRequested
|
||||||
|
signal cancelFadeToDpms
|
||||||
signal requestMonitorOff
|
signal requestMonitorOff
|
||||||
signal requestMonitorOn
|
signal requestMonitorOn
|
||||||
signal requestSuspend
|
signal requestSuspend
|
||||||
@@ -61,11 +63,17 @@ Singleton {
|
|||||||
property var lockMonitor: null
|
property var lockMonitor: null
|
||||||
property var suspendMonitor: null
|
property var suspendMonitor: null
|
||||||
property var lockComponent: null
|
property var lockComponent: null
|
||||||
|
property bool monitorsOff: false
|
||||||
|
|
||||||
function wake() {
|
function wake() {
|
||||||
requestMonitorOn();
|
requestMonitorOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reapplyDpmsIfNeeded() {
|
||||||
|
if (monitorsOff)
|
||||||
|
CompositorService.powerOffMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
function createIdleMonitors() {
|
function createIdleMonitors() {
|
||||||
if (!idleMonitorAvailable) {
|
if (!idleMonitorAvailable) {
|
||||||
console.info("IdleService: IdleMonitor not available, skipping creation");
|
console.info("IdleService: IdleMonitor not available, skipping creation");
|
||||||
@@ -90,8 +98,15 @@ Singleton {
|
|||||||
monitorOffMonitor.timeout = Qt.binding(() => root.monitorTimeout);
|
monitorOffMonitor.timeout = Qt.binding(() => root.monitorTimeout);
|
||||||
monitorOffMonitor.isIdleChanged.connect(function () {
|
monitorOffMonitor.isIdleChanged.connect(function () {
|
||||||
if (monitorOffMonitor.isIdle) {
|
if (monitorOffMonitor.isIdle) {
|
||||||
root.requestMonitorOff();
|
if (SettingsData.fadeToDpmsEnabled) {
|
||||||
|
root.fadeToDpmsRequested();
|
||||||
|
} else {
|
||||||
|
root.requestMonitorOff();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (SettingsData.fadeToDpmsEnabled) {
|
||||||
|
root.cancelFadeToDpms();
|
||||||
|
}
|
||||||
root.requestMonitorOn();
|
root.requestMonitorOn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -131,10 +146,12 @@ Singleton {
|
|||||||
Connections {
|
Connections {
|
||||||
target: root
|
target: root
|
||||||
function onRequestMonitorOff() {
|
function onRequestMonitorOff() {
|
||||||
|
monitorsOff = true;
|
||||||
CompositorService.powerOffMonitors();
|
CompositorService.powerOffMonitors();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRequestMonitorOn() {
|
function onRequestMonitorOn() {
|
||||||
|
monitorsOff = false;
|
||||||
CompositorService.powerOnMonitors();
|
CompositorService.powerOnMonitors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user