Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/idle/fixtures/services/Idle.qml

Raw
import QtQuick

Item {
    // Keep-awake without a native inhibitor: the same state and intents as Idle.qml.
    property bool inhibited: false
    property int toggles: 0

    function stateJson() {
        return JSON.stringify({
            "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;
        toggles++;
        return stateJson();
    }

    // Fixture surface for `features/idle/fixtures/suite.mjs` and the shared task fixture.
    function fixtureState() {
        return {
            "inhibited": inhibited,
            "toggles": toggles
        };
    }
}