import QtQuick import QtQuick.Effects import QtQuick.Layouts import Quickshell import Quickshell.Io import "../../theme" // Avatar (~/.face or AccountsService), greeting, user@host and uptime. Face { id: root readonly property string user: Quickshell.env("USER") || "user" readonly property var avatars: ["file://" + Quickshell.env("HOME") + "/.face", "file://" + Quickshell.env("HOME") + "/.face.icon", "file:///var/lib/AccountsService/icons/" + user] property int avatarIndex: 0 SystemClock { id: clock precision: SystemClock.Minutes } readonly property string greeting: { const h = clock.date.getHours(); return h < 5 ? "Good night" : h < 12 ? "Good morning" : h < 18 ? "Good afternoon" : "Good evening"; } FileView { id: hostname path: "/etc/hostname" } FileView { id: uptime path: "/proc/uptime" } Timer { interval: 60000 running: root.visible && root.desktopVisible repeat: true onTriggered: uptime.reload() } onDesktopVisibleChanged: if (desktopVisible) uptime.reload() readonly property string uptimeText: { const seconds = parseFloat(uptime.text()); if (!Number.isFinite(seconds)) return ""; const d = Math.floor(seconds / 86400), h = Math.floor(seconds % 86400 / 3600), m = Math.floor(seconds % 3600 / 60); return "up " + (d ? d + "d " : "") + (d || h ? h + "h " : "") + m + "m"; } RowLayout { anchors.fill: parent anchors.margins: 14 spacing: 14 Item { readonly property real size: Math.min(root.height - 28, 80) Layout.preferredWidth: size Layout.preferredHeight: size Image { id: avatar anchors.fill: parent source: root.avatarIndex < root.avatars.length ? root.avatars[root.avatarIndex] : "" sourceSize: Qt.size(160, 160) fillMode: Image.PreserveAspectCrop asynchronous: true visible: false onStatusChanged: if (status === Image.Error) root.avatarIndex++ } Rectangle { id: mask anchors.fill: parent radius: width / 2 visible: false layer.enabled: true } MultiEffect { anchors.fill: parent source: avatar maskEnabled: true maskSource: mask visible: avatar.status === Image.Ready } Rectangle { anchors.fill: parent radius: width / 2 visible: avatar.status !== Image.Ready color: Theme.accent Text { anchors.centerIn: parent text: root.user.charAt(0).toUpperCase() color: Theme.accentText font.pixelSize: parent.width * 0.45 font.weight: Font.DemiBold } } } ColumnLayout { Layout.fillWidth: true spacing: 1 Text { text: root.greeting + "," color: Theme.textSecondary font.pixelSize: 12 } Text { text: root.user.charAt(0).toUpperCase() + root.user.slice(1) color: Theme.text font.pixelSize: Math.max(16, root.height * 0.18) font.weight: Font.DemiBold elide: Text.ElideRight Layout.fillWidth: true } Text { text: root.user + "@" + hostname.text().trim() + (root.uptimeText ? " ยท " + root.uptimeText : "") color: Theme.textSecondary font.pixelSize: 10 elide: Text.ElideRight Layout.fillWidth: true } } } }