diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-16 10:54:49 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-16 10:54:49 +0200 |
| commit | 33a20ad0b33467c6980399bb618485b74d66dc04 (patch) | |
| tree | 48d20718d9dd80619125082cec90521b107eb6cb /desktop/modules/user/UserRow.qml | |
| parent | 9a2f7cce971bf2dca54794896d083fdd2f2f1110 (diff) | |
| download | quickshell-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/UserRow.qml')
| -rw-r--r-- | desktop/modules/user/UserRow.qml | 14 |
1 files changed, 12 insertions, 2 deletions
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 } |
