feat: add idle inhibitor for ipc
This commit is contained in:
parent
ef1274d42b
commit
c74a248e1d
3 changed files with 58 additions and 0 deletions
|
|
@ -1,11 +1,18 @@
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
|
||||||
|
import "./IdleInhibitor.qml"
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
property var appLauncherPanel
|
property var appLauncherPanel
|
||||||
property var lockScreen
|
property var lockScreen
|
||||||
|
property IdleInhibitor idleInhibitor
|
||||||
|
|
||||||
target: "globalIPC"
|
target: "globalIPC"
|
||||||
|
|
||||||
|
function toggleIdleInhibitor(): void {
|
||||||
|
idleInhibitor.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
// Toggle Applauncher visibility
|
// Toggle Applauncher visibility
|
||||||
function toggleLauncher(): void {
|
function toggleLauncher(): void {
|
||||||
if (!appLauncherPanel) {
|
if (!appLauncherPanel) {
|
||||||
|
|
|
||||||
43
Helpers/IdleInhibitor.qml
Normal file
43
Helpers/IdleInhibitor.qml
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: idleRoot
|
||||||
|
|
||||||
|
// Example: systemd-inhibit to prevent idle/sleep
|
||||||
|
command: ["systemd-inhibit", "--what=idle:sleep", "--who=noctalia", "--why=User requested", "sleep", "infinity"]
|
||||||
|
|
||||||
|
// Keep process running in background
|
||||||
|
property bool isRunning: running
|
||||||
|
|
||||||
|
onStarted: {
|
||||||
|
console.log("[IdleInhibitor] Process started - idle inhibited")
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: function(exitCode, exitStatus) {
|
||||||
|
console.log("[IdleInhibitor] Process finished:", exitCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Control functions
|
||||||
|
function start() {
|
||||||
|
if (!running) {
|
||||||
|
console.log("[IdleInhibitor] Starting idle inhibitor...")
|
||||||
|
running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
if (running) {
|
||||||
|
// Force stop the process by setting running to false
|
||||||
|
running = false
|
||||||
|
console.log("[IdleInhibitor] Stopping idle inhibitor...")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
if (running) {
|
||||||
|
stop()
|
||||||
|
} else {
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,9 @@ import qs.Widgets.Notification
|
||||||
import qs.Settings
|
import qs.Settings
|
||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
|
|
||||||
|
import "./Helpers/IdleInhibitor.qml"
|
||||||
|
import "./Helpers/IPCHandlers.qml"
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
@ -50,6 +53,10 @@ Scope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IdleInhibitor {
|
||||||
|
id: idleInhibitor
|
||||||
|
}
|
||||||
|
|
||||||
NotificationServer {
|
NotificationServer {
|
||||||
id: notificationServer
|
id: notificationServer
|
||||||
onNotification: function (notification) {
|
onNotification: function (notification) {
|
||||||
|
|
@ -88,6 +95,7 @@ Scope {
|
||||||
IPCHandlers {
|
IPCHandlers {
|
||||||
appLauncherPanel: appLauncherPanel
|
appLauncherPanel: appLauncherPanel
|
||||||
lockScreen: lockScreen
|
lockScreen: lockScreen
|
||||||
|
idleInhibitor: idleInhibitor
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue