forked from Shinonome/dots-hyprland
idle inhibitor: only remember toggled state within same session
This commit is contained in:
@@ -11,6 +11,15 @@ Singleton {
|
|||||||
property string fileName: "states.json"
|
property string fileName: "states.json"
|
||||||
property string filePath: `${root.fileDir}/${root.fileName}`
|
property string filePath: `${root.fileDir}/${root.fileName}`
|
||||||
|
|
||||||
|
property bool ready: false
|
||||||
|
property string previousHyprlandInstanceSignature: ""
|
||||||
|
property bool isNewHyprlandInstance: previousHyprlandInstanceSignature !== states.hyprlandInstanceSignature
|
||||||
|
|
||||||
|
onReadyChanged: {
|
||||||
|
root.previousHyprlandInstanceSignature = root.states.hyprlandInstanceSignature
|
||||||
|
root.states.hyprlandInstanceSignature = Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") || ""
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: fileReloadTimer
|
id: fileReloadTimer
|
||||||
interval: 100
|
interval: 100
|
||||||
@@ -36,6 +45,7 @@ Singleton {
|
|||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: fileReloadTimer.restart()
|
onFileChanged: fileReloadTimer.restart()
|
||||||
onAdapterUpdated: fileWriteTimer.restart()
|
onAdapterUpdated: fileWriteTimer.restart()
|
||||||
|
onLoaded: root.ready = true
|
||||||
onLoadFailed: error => {
|
onLoadFailed: error => {
|
||||||
console.log("Failed to load persistent states file:", error);
|
console.log("Failed to load persistent states file:", error);
|
||||||
if (error == FileViewError.FileNotFound) {
|
if (error == FileViewError.FileNotFound) {
|
||||||
@@ -45,6 +55,9 @@ Singleton {
|
|||||||
|
|
||||||
adapter: JsonAdapter {
|
adapter: JsonAdapter {
|
||||||
id: persistentStatesJsonAdapter
|
id: persistentStatesJsonAdapter
|
||||||
|
|
||||||
|
property string hyprlandInstanceSignature: ""
|
||||||
|
|
||||||
property JsonObject ai: JsonObject {
|
property JsonObject ai: JsonObject {
|
||||||
property string model
|
property string model
|
||||||
property real temperature: 0.5
|
property real temperature: 0.5
|
||||||
|
|||||||
@@ -12,10 +12,22 @@ Singleton {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property alias inhibit: idleInhibitor.enabled
|
property alias inhibit: idleInhibitor.enabled
|
||||||
inhibit: Persistent.states.idle.inhibit
|
inhibit: false
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Persistent
|
||||||
|
function onReadyChanged() {
|
||||||
|
if (!Persistent.isNewHyprlandInstance) {
|
||||||
|
root.inhibit = Persistent.states.idle.inhibit
|
||||||
|
} else {
|
||||||
|
Persistent.states.idle.inhibit = root.inhibit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleInhibit() {
|
function toggleInhibit() {
|
||||||
Persistent.states.idle.inhibit = !Persistent.states.idle.inhibit
|
root.inhibit = !root.inhibit
|
||||||
|
Persistent.states.idle.inhibit = root.inhibit
|
||||||
}
|
}
|
||||||
|
|
||||||
IdleInhibitor {
|
IdleInhibitor {
|
||||||
|
|||||||
Reference in New Issue
Block a user