Merge pull request #747 from oluijks/user-display-name

HostService: add user display name and use it in UI
This commit is contained in:
Lemmy
2025-11-14 14:02:13 -05:00
committed by GitHub
5 changed files with 47 additions and 4 deletions
+40
View File
@@ -14,6 +14,28 @@ Singleton {
property bool isNixOS: false
property bool isReady: false
// User info
readonly property string username: (Quickshell.env("USER") || "")
readonly property string envRealName: (Quickshell.env("NOCTALIA_REALNAME") || "")
property string realName: ""
readonly property string displayName: {
// Explicit override
if (envRealName && envRealName.length > 0)
return envRealName
// Name from getent
if (realName && realName.length > 0)
return realName
// Fallback: capitalized $USER
if (username && username.length > 0)
return username.charAt(0).toUpperCase() + username.slice(1)
// Last resort: placeholder
return "User"
}
function init() {
Logger.i("HostService", "Service started")
}
@@ -111,4 +133,22 @@ Singleton {
stdout: StdioCollector {}
stderr: StdioCollector {}
}
// Resolve GECOS real name once on startup
Process {
id: realNameProcess
command: ["sh", "-c", "getent passwd \"$USER\" | cut -d: -f5 | cut -d, -f1"]
running: true
stdout: StdioCollector {
onStreamFinished: {
const name = String(text || "").trim()
if (name.length > 0) {
root.realName = name
Logger.i("HostService", "resolved real name", name)
}
}
}
stderr: StdioCollector {}
}
}