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/UserRow.qml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'desktop/modules/user/UserRow.qml') diff --git a/desktop/modules/user/UserRow.qml b/desktop/modules/user/UserRow.qml index b67d591..311c6df 100644 --- a/desktop/modules/user/UserRow.qml +++ b/desktop/modules/user/UserRow.qml @@ -16,7 +16,7 @@ import QtQuick import "../.." import "User.js" as U -// The drawer's greeting: avatar, login name, real name. It re-reads each time +// The drawer's greeting: avatar, a random greeting, real name. It re-reads each time // it becomes visible, which is every drawer open and every return from a // page, so a save on the user page shows here on the way back. Rectangle { @@ -38,6 +38,16 @@ Rectangle { onVisibleChanged: if (visible) read() Component.onCompleted: read() + // Read on creation, which is every drawer open, so an edit to the file + // shows on the next one with no watch. + property string greeting: "Hello " + Quickshell.env("USER") + FileView { + path: (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/quickshell/greetings" + printErrors: false + onLoaded: row.greeting = U.greeting(text(), Quickshell.env("USER")) + onLoadFailed: row.greeting = U.greeting("", Quickshell.env("USER")) + } + Process { id: reader command: [Qt.resolvedUrl("userctl").toString().replace(/^file:\/\//, ""), "get"] @@ -78,7 +88,7 @@ Rectangle { verticalCenter: parent.verticalCenter } spacing: 2 Text { - text: "Hello " + Quickshell.env("USER") + text: row.greeting font { family: Theme.fontFamily; pixelSize: Theme.fontSize + 2; bold: true } color: Theme.text } -- cgit v1.2.3