summaryrefslogtreecommitdiff
path: root/services/Persistent.qml
diff options
context:
space:
mode:
Diffstat (limited to 'services/Persistent.qml')
-rw-r--r--services/Persistent.qml27
1 files changed, 27 insertions, 0 deletions
diff --git a/services/Persistent.qml b/services/Persistent.qml
new file mode 100644
index 0000000..3a911bf
--- /dev/null
+++ b/services/Persistent.qml
@@ -0,0 +1,27 @@
+import QtQuick
+import Quickshell
+import Quickshell.Io
+import qs.utils
+
+Scope {
+ id: root
+ property alias adapter: fileView.adapter
+ property alias fileView: fileView
+ property string fileDir: Directories.state
+ property string fileName: "states.json"
+ property string filePath: `${root.fileDir}/${root.fileName}`
+
+ FileView {
+ id: fileView
+ path: root.filePath
+ watchChanges: true
+ onFileChanged: reload()
+ onAdapterUpdated: writeAdapter()
+ onLoadFailed: error => {
+ console.log("Failed to load persistent states file:", error);
+ if (error == FileViewError.FileNotFound) {
+ writeAdapter();
+ }
+ }
+ }
+}