mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
Merge pull request #747 from oluijks/user-display-name
HostService: add user display name and use it in UI
This commit is contained in:
@@ -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 {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user