Compare commits
No commits in common. "22ea9b0df1e7221cf94002a8c9690cdee182b126" and "d90f9cbf94a0e5ddeee3f02177da5993b5de0df0" have entirely different histories.
22ea9b0df1
...
d90f9cbf94
1 changed files with 7 additions and 30 deletions
|
|
@ -1,50 +1,27 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import "." as M
|
import "." as M
|
||||||
|
|
||||||
M.BarIcon {
|
M.BarIcon {
|
||||||
id: root
|
id: root
|
||||||
color: root.active ? (parent?.accentColor ?? M.Theme.base05) : M.Theme.base04
|
color: root.active ? (parent?.accentColor ?? M.Theme.base05) : M.Theme.base04
|
||||||
tooltip: {
|
tooltip: "Idle inhibition: " + (root.active ? "active" : "inactive")
|
||||||
const parts = ["Idle inhibition: " + (root.active ? "active" : "inactive")];
|
|
||||||
if (root._inhibitors)
|
|
||||||
parts.push(root._inhibitors);
|
|
||||||
return parts.join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
property bool active: false
|
property bool active: false
|
||||||
property string _inhibitors: ""
|
|
||||||
|
|
||||||
icon: root.active ? "\uF06E" : "\uF070"
|
icon: root.active ? "\uF06E" : "\uF070"
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: inhibitor
|
id: toggle
|
||||||
command: ["systemd-inhibit", "--what=idle", "--who=nova-shell", "--why=user", "sleep", "infinity"]
|
command: ["sh", "-c", root.active ? "pkill -x systemd-inhibit || true" : "systemd-inhibit --what=idle --who=nova-shell --why=user sleep infinity &"]
|
||||||
running: root.active
|
|
||||||
}
|
|
||||||
|
|
||||||
// Poll current inhibitors
|
|
||||||
Process {
|
|
||||||
id: listProc
|
|
||||||
running: true
|
|
||||||
command: ["sh", "-c", "systemd-inhibit --list 2>/dev/null | grep -i idle | awk '{print $NF}' | sort -u | tr '\\n' ', ' | sed 's/, $//'"]
|
|
||||||
stdout: StdioCollector {
|
|
||||||
onStreamFinished: root._inhibitors = text.trim() ? "Blocked by: " + text.trim() : ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
interval: 5000
|
|
||||||
running: root._hovered
|
|
||||||
repeat: true
|
|
||||||
triggeredOnStart: true
|
|
||||||
onTriggered: listProc.running = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: root.active = !root.active
|
onClicked: {
|
||||||
|
root.active = !root.active;
|
||||||
|
toggle.running = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue