Krolyxon
Commit f0edd5d

Branches

Refs →

aurora.configquickshellauroraSettings.qml

72 lines · 2.6 KB · QML

1pragma Singleton
2import QtQuick
3import Quickshell
4import Quickshell.Io
5
6// User knobs persisted to ~/.config/aurora/settings.json (outside the shell dir, so syncing the
7// config never clobbers it). Written on every change, re-read when edited by hand.
8Singleton {
9 id: root
10 readonly property string file: Quickshell.env("HOME") + "/.config/aurora/settings.json"
11
12 // defaults live here; reset() puts them back
13 readonly property var defaults: ({
14 fontSize: 12, wsFontSize: 11, barHeight: 22, barAlpha: 1.0, panelAlpha: 0.88, accentIndex: 14,
15 osdTimeout: 1500, desktopClock: true, desktopViz: true, vizBars: 64,
16 dock: true, dockPinned: ["foot", "librewolf", "pcmanfm", "obsidian"], wallFolder: "dusky-dark"
17 })
18
19 property alias fontSize: a.fontSize
20 property alias wsFontSize: a.wsFontSize
21 property alias barHeight: a.barHeight
22 property alias barAlpha: a.barAlpha
23 property alias panelAlpha: a.panelAlpha
24 property alias accentIndex: a.accentIndex
25 property alias osdTimeout: a.osdTimeout
26 property alias desktopClock: a.desktopClock
27 property alias desktopViz: a.desktopViz
28 property alias vizBars: a.vizBars
29 property alias dock: a.dock
30 property alias dockPinned: a.dockPinned
31 property alias wallFolder: a.wallFolder
32
33 function reset() {
34 for (var k in defaults) a[k] = defaults[k]
35 }
36 function togglePin(id) {
37 var l = dockPinned.slice(), i = l.indexOf(id)
38 if (i >= 0) l.splice(i, 1); else l.push(id)
39 dockPinned = l
40 }
41
42 FileView {
43 id: fv
44 path: root.file
45 watchChanges: true
46 onFileChanged: reload()
47 onAdapterUpdated: writeAdapter()
48 onLoadFailed: err => {
49 if (err === FileViewError.FileNotFound)
50 Quickshell.execDetached(["sh", "-c", 'mkdir -p "${1%/*}"', "sh", root.file])
51 writeLater.start()
52 }
53 adapter: JsonAdapter {
54 id: a
55 property int fontSize: 12
56 property int wsFontSize: 11
57 property int barHeight: 22
58 property real barAlpha: 1.0
59 property real panelAlpha: 0.88
60 property int accentIndex: 14
61 property int osdTimeout: 1500
62 property bool desktopClock: true
63 property bool desktopViz: true
64 property int vizBars: 64
65 property bool dock: true
66 property list<string> dockPinned: ["foot", "librewolf", "pcmanfm", "obsidian"]
67 property string wallFolder: "dusky-dark"
68 }
69 }
70 // first run: create the file once the directory exists
71 Timer { id: writeLater; interval: 300; onTriggered: fv.writeAdapter() }
72}