aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/autostart/test_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/test_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/test_autostart.js')
-rw-r--r--desktop/modules/autostart/test_autostart.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/desktop/modules/autostart/test_autostart.js b/desktop/modules/autostart/test_autostart.js
index 00ba6b2..e380032 100644
--- a/desktop/modules/autostart/test_autostart.js
+++ b/desktop/modules/autostart/test_autostart.js
@@ -55,6 +55,13 @@ const added = A.add(file, 'say "hi"').split("\n");
assert.strictEqual(added[5], ' hl.exec_cmd("say \\"hi\\"")');
assert.strictEqual(added[6], "end)");
assert.strictEqual(A.add("nothing here", "x"), null);
+// With a shutdown hook after it, still inside the start hook: the file's
+// last end) once took a login command and ran it at logout.
+const both = file + 'hl.on("hyprland.shutdown", function()\n hl.exec_cmd("bye")\nend)\n';
+const into = A.add(both, "x").split("\n");
+assert.strictEqual(into[5], ' hl.exec_cmd("x")');
+assert.strictEqual(into[6], "end)");
+assert.strictEqual(into[into.length - 2], "end)");
// A stale entry, its line changed since parse, refuses rather than edits.
assert.strictEqual(A.toggle(off, e[0]), null);