per-monitor handling of sidebar opening

This commit is contained in:
end-4
2025-04-14 12:18:33 +02:00
parent a139c29a2b
commit 9f0deefec4
5 changed files with 113 additions and 17 deletions
@@ -6,6 +6,7 @@ pragma Singleton
Singleton {
property string time: Qt.formatDateTime(clock.date, "hh:mm")
property string date: Qt.formatDateTime(clock.date, "dddd, dd/MM")
property string uptime: "0h, 0m"
SystemClock {
id: clock
@@ -13,4 +14,34 @@ Singleton {
precision: SystemClock.Minutes
}
Timer {
interval: 10
running: true
repeat: true
onTriggered: {
fileUptime.reload()
const textUptime = fileUptime.text()
const uptimeSeconds = Number(textUptime.split(" ")[0] ?? 0)
// Convert seconds to days, hours, and minutes
const days = Math.floor(uptimeSeconds / 86400)
const hours = Math.floor((uptimeSeconds % 86400) / 3600)
const minutes = Math.floor((uptimeSeconds % 3600) / 60)
// Build the formatted uptime string
let formatted = ""
if (days > 0) formatted += `${days}d`
if (hours > 0) formatted += `${formatted ? ", " : ""}${hours}h`
if (minutes > 0 || !formatted) formatted += `${formatted ? ", " : ""}${minutes}m`
uptime = formatted
interval = ConfigOptions.resources.updateInterval;
}
}
FileView {
id: fileUptime
path: "/proc/uptime"
}
}