Files
I-DeskPet/Modules/ConfigLoader.qml
T
2026-02-16 13:23:06 +01:00

56 lines
1021 B
QML

pragma Singleton
import QtQuick
import Quickshell.Io
import Quickshell
Singleton {
id: root
property alias gifFolder: adapter.gifFolder
property alias maxScaling: adapter.maxScaling
property string configDir: Quickshell.env("HOME") + "/.config/I-DeskPet"
property string configPath: configDir + "/config.json"
Process {
id: dirCheck
running: true
command: [ "test", "-d", root.configDir ]
onExited: function( exitCode ) {
if ( exitCode !== 0 ) {
console.log( "creating dir" )
dirCreate.running = true
}
}
}
Process {
id: dirCreate
running: false
command: [ "mkdir", "-p", root.configDir ]
onExited: function(): void {
console.log( "Created config directory:", root.configDir )
}
}
FileView {
id: watcher
path: root.configPath
watchChanges: true
onFileChanged: reload()
onAdapterUpdated: writeAdapter()
JsonAdapter {
id: adapter
property string gifFolder: Quickshell.shellDir + "/Gifs"
property real maxScaling: 1
}
}
}