repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

feat(nuguland): idle is a toggle, not a popout

64d42d0e469da8ec8be833fe5dfd703cbf0482ed

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Keep-awake never had a real timer — the inhibit always followed a single
bool. So drop the duration options (10/30/60m), the activity/reason
bookkeeping, and the whole idle popout (panel, loader case, content-size,
catalog entry, openIdle IPC). The bar chip now toggles infinite inhibit
on click; its prominent active treatment is the only state UI needed.
Hover-switch skips idle since it has no popout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Changed files (5)

quickshell/nuguland/Bar.qml

Modified
281 281 networkService: root.networkService
282 282 bluetoothService: root.bluetoothService
283 283 powerService: root.powerService
284 - idleService: root.idleService
285 284 lockService: root.lockService
286 285 barWindow: root
600 599 checked: chip.selected
602 601 onEntered: {
602 + // idle is a toggle, not a popout — no hover-switch
603 + if (chip.popoutName === "idle")
604 + return ;
603 606 if (root.surfaces)
604 607 root.surfaces.hoverRegisteredPopout(chip.popoutName);
607 610 onActivated: {
611 + if (chip.popoutName === "idle") {
612 + if (root.usageService)
613 + root.usageService.record("idle");
615 + if (root.idleService)
616 + root.idleService.toggle();
618 + return ;
608 620 if (root.surfaces)
609 621 root.activatePopout(chip.popoutName);

quickshell/nuguland/Idle.qml

Modified
2 2 import QtQuick
3 3 import Quickshell
4 4 import Quickshell.Wayland
6 +// Keep-awake: a single infinite idle inhibitor, on until toggled off.
7 +// No durations, no timer — the inhibit follows `enabled` directly.
6 8 Item {
7 9 id: root
9 11 property bool enabled: false
10 - property int durationMinutes: 0
11 - property int remainingMinutes: 0
12 - property string reason: ""
13 - property string activity: ""
14 - property string enabledSince: ""
15 - property var lastAction: ({
16 - })
17 - readonly property int defaultDurationMinutes: 30
18 - readonly property var availableDurations: [15, 30, 60, 120]
19 - readonly property var boundedActions: ["enable", "disable", "toggle", "set-activity", "expire"]
21 - function clampDuration(minutes) {
22 - const value = Number(minutes);
23 - if (!isFinite(value) || value <= 0)
24 - return defaultDurationMinutes;
26 - return Math.max(1, Math.round(value));
27 - }
29 - function nowStamp() {
30 - return new Date().toISOString();
31 - }
33 - function compactObject() {
34 - return {
35 - "label": enabled ? "awake" : "normal",
36 - "role": enabled ? "ui.accent" : "ui.minor",
37 - "tooltip": enabled ? `Keep awake: ${reason}` : "Normal idle behavior"
38 - };
39 - }
41 - function idlePanelContract() {
42 - return {
43 - "source": "Nuguland IdleInhibit.qml plus Nuguland Privacy.qml",
44 - "ownedBy": "PopoutHost.qml inline IdlePanel",
45 - "keepAwakePanel": true,
46 - "activeSinceChip": true,
47 - "durationChips": true,
48 - "activityRows": true,
49 - "privacyStatusRows": true,
50 - "nativeIdleInhibitorRoute": true,
51 - "serviceActionsOnly": true,
52 - "durations": availableDurations,
53 - "quickActivities": ["focus", "video-call", "presentation", "break"],
54 - "privacySignals": ["idleInhibited", "activity"]
55 - };
56 - }
58 - function stateObject() {
59 - return {
60 - "backend": "Idle.qml",
61 - "usesNativeIdleInhibitor": true,
62 - "helperProcesses": [],
63 - "serviceOwnedActions": true,
64 - "boundedActions": boundedActions,
65 - "idlePanelContract": idlePanelContract(),
66 - "defaultDurationMinutes": defaultDurationMinutes,
67 - "availableDurations": availableDurations,
68 - "surface": "zero-size-idle-inhibitor-window",
69 - "enabled": enabled,
70 - "durationMinutes": durationMinutes,
71 - "remainingMinutes": enabled ? remainingMinutes : 0,
72 - "reason": reason,
73 - "activity": activity,
74 - "enabledSince": enabledSince,
75 - "compact": compactObject(),
76 - "privacy": {
77 - "idleInhibited": enabled,
78 - "activity": activity
79 - },
80 - "lastAction": lastAction
81 - };
82 - }
84 13 function stateJson() {
85 - return JSON.stringify(stateObject());
14 + return JSON.stringify({
15 + "backend": "Idle.qml",
16 + "usesNativeIdleInhibitor": true,
17 + "enabled": enabled,
18 + "compact": {
19 + "label": enabled ? "awake" : "normal",
20 + "role": enabled ? "ui.accent" : "ui.minor",
21 + "tooltip": enabled ? "Keep awake — on until toggled off" : "Normal idle behavior"
22 + }
23 + });
88 - function enable(minutes, why) {
89 - const duration = clampDuration(minutes);
26 + function enable() {
90 27 enabled = true;
91 - durationMinutes = duration;
92 - remainingMinutes = duration;
93 - reason = String(why || "manual");
94 - enabledSince = nowStamp();
95 - lastAction = {
96 - "kind": "enable",
97 - "minutes": duration,
98 - "reason": reason
99 - };
100 28 return stateJson();
103 31 function disable() {
104 32 enabled = false;
105 - remainingMinutes = 0;
106 - lastAction = {
107 - "kind": "disable"
108 - };
109 33 return stateJson();
112 - function toggle(minutes, why) {
113 - const duration = clampDuration(minutes);
114 - const next = !enabled;
115 - if (next) {
116 - enabled = true;
117 - durationMinutes = duration;
118 - remainingMinutes = duration;
119 - reason = String(why || "manual");
120 - enabledSince = nowStamp();
121 - } else {
122 - enabled = false;
123 - remainingMinutes = 0;
124 - }
125 - lastAction = {
126 - "kind": "toggle",
127 - "enabled": next,
128 - "minutes": duration,
129 - "reason": String(why || "manual")
130 - };
131 - return stateJson();
132 - }
134 - function setActivity(name) {
135 - activity = String(name);
136 - lastAction = {
137 - "kind": "set-activity",
138 - "activity": activity
139 - };
140 - return stateJson();
141 - }
143 - function expire() {
144 - enabled = false;
145 - remainingMinutes = 0;
146 - lastAction = {
147 - "kind": "expire"
148 - };
36 + function toggle() {
37 + enabled = !enabled;
149 38 return stateJson();

quickshell/nuguland/PopoutHost.qml

Modified
21 21 required property QtObject networkService
22 22 required property QtObject bluetoothService
23 23 required property QtObject powerService
24 - required property QtObject idleService
25 24 required property QtObject lockService
26 25 required property var barWindow
27 26 readonly property var contentSize: surfaces ? surfaces.popoutContentSize(surfaces.popoutName) : ({
73 72 return connectivityContent;
74 73 case "power":
75 74 return powerContent;
76 - case "idle":
77 - return idleContent;
78 75 default:
79 76 return helpContent;
651 - Component {
652 - id: idleContent
654 - IdlePanel {
655 - theme: root.theme
656 - idleService: root.idleService
657 - width: parent ? parent.width : 0
663 648 Component {
664 649 id: helpContent
1689 - component IdlePanel: Column {
1690 - id: root
1692 - required property QtObject theme
1693 - required property QtObject idleService
1694 - property var state: idleService ? Util.parseJson(idleService.stateJson(), {
1695 - "active": false,
1696 - "reason": "",
1697 - "remainingSeconds": 0,
1698 - "idlePanelContract": {
1700 - }) : ({
1701 - "active": false,
1702 - "reason": "",
1703 - "remainingSeconds": 0,
1704 - "idlePanelContract": {
1706 - })
1707 - readonly property var panel: state.idlePanelContract || ({
1708 - })
1711 - spacing: 8
1712 - width: parent ? parent.width : 0
1714 - NuguText {
1715 - theme: root.theme
1716 - variant: "title"
1717 - text: root.state.active ? "Idle inhibited" : "Idle allowed"
1718 - width: parent.width
1719 - elide: Text.ElideRight
1722 - NuguText {
1723 - theme: root.theme
1724 - text: root.state.reason || "No keep-awake request"
1725 - width: parent.width
1726 - elide: Text.ElideRight
1729 - Row {
1730 - width: parent.width
1731 - spacing: 8
1733 - Repeater {
1734 - model: [15, 30, 60]
1736 - delegate: Rectangle {
1737 - required property int modelData
1739 - width: Math.floor((root.width - 16) / 3)
1740 - height: 34
1741 - radius: 10
1742 - color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.12) : "transparent"
1743 - border.width: 0
1744 - border.color: root.theme ? root.theme.ui.accent : "transparent"
1746 - NuguText {
1747 - anchors.centerIn: parent
1748 - theme: root.theme
1749 - variant: "meta"
1750 - text: `${parent.modelData}m`
1753 - MouseArea {
1754 - anchors.fill: parent
1755 - onClicked: {
1756 - if (root.idleService)
1757 - root.state = Util.parseJson(root.idleService.toggle(parent.modelData, "manual"), root.state);
1770 1674 component ClipboardPanel: Column {
1771 1675 id: root

quickshell/nuguland/SurfaceManager.qml

Modified
115 115 "width": width,
116 116 "height": heightBudget(480)
118 - case "idle":
119 - return {
120 - "width": width,
121 - "height": heightBudget(340)
122 - };
123 118 default:
124 119 return {
125 120 "width": width,
214 209 "component": "power-battery",
215 210 "source": "Power.qml",
216 211 "visual": ["battery", "profile", "session", "confirmation"]
217 - },
218 - "idle": {
219 - "component": "idle-privacy",
220 - "source": "Idle.qml",
221 - "visual": ["inhibit", "duration", "activity", "privacy"]

quickshell/nuguland/shell.qml

Modified
704 704 return idle.stateJson();
707 - function idleEnable(minutes: real, reason: string) : string {
708 - return idle.enable(minutes, reason);
707 + function idleToggle() : string {
708 + return idle.toggle();
711 711 function idleDisable() : string {
712 712 return idle.disable();
715 - function idleToggle(minutes: real, reason: string) : string {
716 - return idle.toggle(minutes, reason);
719 - function idleSetActivity(name: string) : string {
720 - return idle.setActivity(name);
723 - function idleExpire() : string {
724 - return idle.expire();
727 - function openIdle() : string {
728 - return surfaceManager.openRegisteredPopout("idle");
731 715 function privilegeState() : string {
732 716 return privilege.stateJson();