Krolyxon
Commit 18cfb4c

Branches

Refs →

aurora18cfb4c

aurora: settings reset waits for hypr.lua to be written before reloading

Author
krolyxon
Date
2026-10-20 01:06 +0530
Parent
b390172
Commit
18cfb4c2b47a063bac3a53ae617a4a3d8cb4a78f

+21 −14

1 file changed

  1. M .config/quickshell/aurora/HyprConf.qml +21 −14
M .config/quickshell/aurora/HyprConf.qml View
@@ -53,24 +53,24 @@ Singleton {
5353 applyTimer.restart() // coalesces slider drags into one hyprctl call
5454 saveTimer.restart()
5555 }
56− function reset(opt) {
57− if (!isSet(opt)) return
58− var o = Object.assign({}, overrides)
59− delete o[opt]
60− overrides = o
61− save()
62− reloadProc.running = true // config-only reload re-reads the repo files + the new hypr.lua
63− }
64− function resetAll(prefixes) { // e.g. ["input:"]: reset every override under those sections
65− var o = Object.assign({}, overrides), changed = false
56+ function reset(opt) { resetAll([opt]) }
57+ // e.g. ["input:", "cursor:"]: drop every override under those sections, then reload Hyprland's config so the
58+ // repo values come back. The reload waits for hypr.lua to be written (luaFile.onSaved): reloading right after
59+ // setText() raced the async write and Hyprland re-read the old overrides.
60+ function resetAll(prefixes) {
61+ var o = Object.assign({}, overrides), n = 0
6662 for (var k in o)
6763 for (var i = 0; i < prefixes.length; i++)
68− if (k.indexOf(prefixes[i]) === 0) { delete o[k]; changed = true; break }
69− if (!changed) return
64+ if (k.indexOf(prefixes[i]) === 0) { delete o[k]; n++; break }
65+ pending = {} // a slider drag still waiting to be applied would undo the reset
66+ applyTimer.stop()
67+ saveTimer.stop()
68+ if (n === 0) { message = ""; refresh(); return } // nothing overridden: already the config values
7069 overrides = o
70+ reloadAfterSave = true
7171 save()
72− reloadProc.running = true
7372 }
73+ property bool reloadAfterSave: false
7474 function refresh() {
7575 readProc.command = ["sh", "-c", 'for o; do hyprctl -j getoption "$o" | tr -d "\\n"; echo; done', "sh"]
7676 .concat(Object.keys(types))
@@ -169,7 +169,14 @@ Singleton {
169169 try { root.overrides = JSON.parse(text()) || {} } catch (e) { root.overrides = {} }
170170 }
171171 }
172− FileView { id: luaFile; path: root.dir + "/hypr.lua"; preload: false; printErrors: false } // write-only
172+ FileView { // write-only
173+ id: luaFile
174+ path: root.dir + "/hypr.lua"
175+ preload: false
176+ printErrors: false
177+ onSaved: if (root.reloadAfterSave) { root.reloadAfterSave = false; reloadProc.running = true }
178+ onSaveFailed: err => { root.reloadAfterSave = false; root.message = "could not write hypr.lua (error " + err + ")" }
179+ }
173180
174181 Component.onCompleted: refresh()
175182 }