diff --git a/settings/quickshell.nix b/settings/quickshell.nix index 944bc6a..9fcd675 100644 --- a/settings/quickshell.nix +++ b/settings/quickshell.nix @@ -4666,6 +4666,7 @@ in let pos = batteryWidget.mapToItem(bar.contentItem, 0, batteryWidget.height / 2); batteryDropdown.dropdownY = pos.y; brightRead.running = true; // refresh sliders on open + caffRead.running = true; // and the caffeine state }); } @@ -6092,6 +6093,56 @@ in } } + + // Caffeine card — parks hypridle so nothing locks, + // blanks or suspends. State is re-read on open, so a + // hypridle restart can't leave the switch lying. + Card { + id: caffCard + width: parent.width + property bool on: false + + Item { + width: parent.width + height: 20 + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + SIcon { + anchors.verticalCenter: parent.verticalCenter + text: "coffee" + color: caffCard.on ? Theme.base0D : Theme.base05 + font.pixelSize: 15 + } + SText { + anchors.verticalCenter: parent.verticalCenter + text: "Caffeine" + font.weight: Font.Medium + } + } + ToggleSwitch { + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + on: caffCard.on + onToggled: (v) => { + caffCard.on = v; + caffSet.command = [Commands.systemctl, "--user", v ? "stop" : "start", "hypridle.service"]; + caffSet.running = true; + } + } + } + + Process { id: caffSet } + Process { + id: caffRead + command: [Commands.systemctl, "--user", "is-active", "hypridle.service"] + stdout: StdioCollector { + // is-active exits non-zero when stopped; the + // word on stdout is what matters here. + onStreamFinished: caffCard.on = text.trim() !== "active" + } + } + } // Brightness card — screen + keyboard backlight. // Values are read on dropdown open (brightRead); writes // are debounced latest-wins so a drag doesn't spawn a