aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/user/test_user.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-16 10:54:49 +0200
committerDanilo M. <danix@danix.xyz>2026-10-16 10:54:49 +0200
commit33a20ad0b33467c6980399bb618485b74d66dc04 (patch)
tree48d20718d9dd80619125082cec90521b107eb6cb /desktop/modules/user/test_user.js
parent9a2f7cce971bf2dca54794896d083fdd2f2f1110 (diff)
downloadquickshell-33a20ad0b33467c6980399bb618485b74d66dc04.tar.gz
quickshell-33a20ad0b33467c6980399bb618485b74d66dc04.zip
feat(user): a random greeting on each drawer open
The greeting row picks one at random from ~/.config/quickshell/greetings, one per line with {user} for the login name, # comments and blank lines skipped; without the file, five built-in ones. The row is rebuilt on every drawer open, so the file is read then with no watch, and the last pick is kept in User.js, a shared .pragma library, so the same greeting never shows twice running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/user/test_user.js')
-rw-r--r--desktop/modules/user/test_user.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/desktop/modules/user/test_user.js b/desktop/modules/user/test_user.js
index 3f1a73d..cf38609 100644
--- a/desktop/modules/user/test_user.js
+++ b/desktop/modules/user/test_user.js
@@ -18,7 +18,7 @@ const assert = require("assert");
const src = fs.readFileSync(__dirname + "/User.js", "utf8")
.replace(/^\.pragma library$/m, "");
-const U = new Function(src + "\nreturn { parse, keys, locales, gitName, places };")();
+const U = new Function(src + "\nreturn { parse, keys, locales, gitName, places, greeting };")();
// parse: key=value lines; a value may itself hold "=".
assert.deepStrictEqual(U.parse("name=Jane Doèr\nlocation=a=b\n\n"),
@@ -64,4 +64,12 @@ assert.deepStrictEqual(U.places(nominatim), [
assert.deepStrictEqual(U.places(""), []);
assert.deepStrictEqual(U.places("<html>rate limited</html>"), []);
+
+// greeting: comments and blanks skipped, {user} filled, never the same twice
+// running, and the built-in set when the file has nothing.
+assert.strictEqual(U.greeting("# c\n\n Yo {user} \n", "jd", 0), "Yo jd");
+assert.strictEqual(U.greeting("a\nb", "jd", 0), "b");
+assert.strictEqual(U.greeting("a\nb", "jd", 0), "a");
+assert.ok(U.greeting("", "jd", 0).endsWith("jd"));
+
console.log("test_user: ok");