Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/Idle.qml

Raw
import QtQuick
import Quickshell
import Quickshell.Wayland

// Keep-awake: a single infinite idle inhibitor, on until toggled off.
// No durations, no timer — the inhibit follows `enabled` directly.
Item {
    id: root

    property bool inhibited: false

    function stateJson() {
        return JSON.stringify({
            "backend": "Idle.qml",
            "usesNativeIdleInhibitor": true,
            "enabled": inhibited,
            "compact": {
                "label": inhibited ? "awake" : "normal",
                "role": inhibited ? "ui.accent" : "ui.minor",
                "tooltip": inhibited ? "Keep awake — on until toggled off" : "Normal idle behavior"
            }
        });
    }

    function enable() {
        inhibited = true;
        return stateJson();
    }

    function disable() {
        inhibited = false;
        return stateJson();
    }

    function toggle() {
        inhibited = !inhibited;
        return stateJson();
    }

    PanelWindow {
        id: idleWindow

        implicitWidth: 0
        implicitHeight: 0
        color: "transparent"

        mask: Region {}
    }

    IdleInhibitor {
        enabled: root.inhibited
        window: idleWindow
    }
}