aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/autostart/Autostart.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-10 10:06:05 +0100
committerDanilo M. <danix@danix.xyz>2026-11-10 10:06:05 +0100
commitb5654d5ad7642d755ce7054ffbc281b0bc84c505 (patch)
treea8de9a55ea68b49acbdae1226221126089204001 /desktop/modules/autostart/Autostart.js
parent57813295282ea5c67ee5c8c7dc49640e2c7224bf (diff)
downloadquickshell-b5654d5ad7642d755ce7054ffbc281b0bc84c505.tar.gz
quickshell-b5654d5ad7642d755ce7054ffbc281b0bc84c505.zip
fix(autostart): add entries to the start hook, not the last end)
Autostart.add inserted before the file's last `end)`. Since autostart.lua gained a hyprland.shutdown hook after the start hook, a command added from the Autostart page landed in the shutdown hook and would have run at logout instead of login. It now inserts before the `end)` that closes `hl.on("hyprland.start", ...)`, and returns null when there is no start hook. The test covers a file with both hooks; it fails on the old code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/autostart/Autostart.js')
-rw-r--r--desktop/modules/autostart/Autostart.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/desktop/modules/autostart/Autostart.js b/desktop/modules/autostart/Autostart.js
index 81510d7..8fea823 100644
--- a/desktop/modules/autostart/Autostart.js
+++ b/desktop/modules/autostart/Autostart.js
@@ -115,12 +115,15 @@ function remove(text, e) {
return edit(text, e, a => a.splice(e.index, 1));
}
-// A new enabled entry before the hook's closing `end)`, indented like the
-// last entry. Null if there is no `end)` to put it before.
+// A new enabled entry before the closing `end)` of the hyprland.start hook,
+// indented like the last entry. Not the file's last `end)`: a
+// hyprland.shutdown hook after it would run the entry at logout. Null if
+// there is no start hook with an `end)` to put it before.
function add(text, cmd) {
const a = text.split("\n");
+ const start = a.findIndex(l => /^hl\.on\(\s*"hyprland\.start"/.test(l));
let end = -1;
- for (let i = a.length - 1; i >= 0; i--)
+ for (let i = start + 1; start >= 0 && i < a.length; i++)
if (/^end\)\s*$/.test(a[i])) { end = i; break; }
if (end < 0) return null;
const last = parse(text).pop();