From 33a20ad0b33467c6980399bb618485b74d66dc04 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 16 Oct 2026 10:54:49 +0200 Subject: 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 --- desktop/modules/user/test_user.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'desktop/modules/user/test_user.js') 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("rate limited"), []); + +// 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"); -- cgit v1.2.3