rework of IdleButton

This commit is contained in:
Hannes
2026-08-22 21:35:43 +02:00
parent 896264c062
commit 9f8d774efd
6 changed files with 24 additions and 47 deletions
+19 -11
View File
@@ -1,6 +1,7 @@
import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Wayland
import Quickshell.Io
import "../../../config"
import "../states/Idle"
@@ -12,16 +13,29 @@ MouseArea {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
required property PanelWindow panelWindow
IdleInhibitor {
id: idleInhibitor
window: panelWindow
enabled: IdleState.idle
}
IdleMonitor {
id: idleMonitor
enabled: true
timeout: 30
respectInhibitors: true
}
onClicked: {
var newState = IdleState.idle ? 0 : 1
console.log("[IdleButton] Toggling idle: " + (newState ? "enabled" : "disabled"))
idleToggleProc.startDetached()
IdleState.idle = newState
IdleState.idle = !IdleState.idle
console.log("[IdleButton] Toggling idle: " + (IdleState.idle ? "enabled" : "disabled"))
}
Rectangle {
anchors.fill: parent
color: idleButton.containsMouse ? Colors.tertiary : Qt.alpha(Colors.tertiaryContainer, 0.25)
color: idleButton.containsMouse ? Colors.tertiary : idleMonitor.isIdle ? Qt.alpha(Colors.secondary, 0.25) : Qt.alpha(Colors.tertiaryContainer, 0.25)
radius: Config.radius_fun(idleButton.height)
border.width: Config.border_width
border.color: (
@@ -42,10 +56,4 @@ MouseArea {
)
}
}
Process {
id: idleToggleProc
command: ["sh", "-c", Config.configDir + "/modules/bar/scripts/Idle.sh"]
running: false
}
}