pragma Singleton import QtQuick import Quickshell import Quickshell.Io // hypridle timeouts from the settings app. The repo's hypridle.conf keeps `general {}` and sources // ~/.config/aurora/hypridle.conf, which this writes (also on startup when it's missing: hypridle errors // on a missing source). hypridle is restarted through Hyprland's exec so it lives outside aurora's // systemd unit (an aurora restart would kill it otherwise). Seconds, 0 = never. Singleton { id: root readonly property string file: Quickshell.env("HOME") + "/.config/aurora/hypridle.conf" readonly property int dim: Settings.idleDim readonly property int screenOff: Settings.idleOff readonly property int lock: Settings.idleLock readonly property int suspend: Settings.idleSuspend function setTimeout(key, v) { Settings[key] = Math.max(0, Math.round(v)) } // any change (slider, Settings.reset(), hand edit of settings.json) rewrites the file onDimChanged: writeTimer.restart() onScreenOffChanged: writeTimer.restart() onLockChanged: writeTimer.restart() onSuspendChanged: writeTimer.restart() function render() { var off = "hyprctl dispatch 'hl.dsp.dpms({action=\"off\"})'" var on = "hyprctl dispatch 'hl.dsp.dpms({action=\"on\"})'" var l = ["# generated by aurora's settings app (Idle.qml); edit there, not here", ""] function listener(t, timeout, resume) { if (t <= 0) return l.push("listener {", " timeout = " + t, " on-timeout = " + timeout) if (resume) l.push(" on-resume = " + resume) l.push("}", "") } listener(dim, "brightnessctl -s set 5", "brightnessctl -r") // dim the panel, restore on activity listener(screenOff, off, on + " && brightnessctl -r") listener(lock, "loginctl lock-session", "") listener(suspend, "systemctl suspend", "") return l.join("\n") } function write() { fv.setText(render()) restartTimer.restart() } Timer { id: writeTimer; interval: 800; onTriggered: root.write() } Timer { id: restartTimer interval: 300 onTriggered: Quickshell.execDetached(["sh", "-c", "pkill -x hypridle; for i in 1 2 3 4 5 6 7 8 9 10; do pgrep -x hypridle >/dev/null || break; sleep 0.1; done; " + "hyprctl dispatch 'hl.dsp.exec_cmd(\"hypridle\")' >/dev/null"]) } FileView { id: fv path: root.file printErrors: false onLoadFailed: err => { if (err === FileViewError.FileNotFound) root.write() } } }