- Dock drag-to-reorder for pinned apps (insertion gap, quick-slide vs dwell) - Fullscreen detection: scan all windows via HyprlandData.windowList - IdleCoordinator, GlobalStates, Session.qml updates - Deploy script, qmldir, settings, wallpaper, visualizer fixes - sessiond server, memory module updates Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
2.3 KiB
QML
64 lines
2.3 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
import qs
|
|
import qs.modules.common
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
/**
|
|
* A nice wrapper for date and time strings.
|
|
*/
|
|
Singleton {
|
|
property var clock: SystemClock {
|
|
id: clock
|
|
precision: {
|
|
if (Config.options.time.secondPrecision || GlobalStates.screenLocked)
|
|
return SystemClock.Seconds;
|
|
return SystemClock.Minutes;
|
|
}
|
|
}
|
|
property string time: Qt.locale().toString(clock.date, Config.options?.time.format ?? "hh:mm")
|
|
property string shortDate: Qt.locale().toString(clock.date, Config.options?.time.shortDateFormat ?? "dd/MM")
|
|
property string date: Qt.locale().toString(clock.date, Config.options?.time.dateWithYearFormat ?? "dd/MM/yyyy")
|
|
property string longDate: Qt.locale().toString(clock.date, Config.options?.time.dateFormat ?? "dddd, dd/MM")
|
|
property string collapsedCalendarFormat: Qt.locale().toString(clock.date, "dddd, MMMM dd")
|
|
property string uptime: "0h, 0m"
|
|
|
|
Timer {
|
|
// Uptime advances one minute per minute; reload /proc/uptime once a
|
|
// minute, not 100x/second. (Was interval: 10 — a 10ms busy-reload of a
|
|
// disk file, an always-on drain independent of the SystemClock above.)
|
|
interval: 60000
|
|
running: true
|
|
repeat: true
|
|
triggeredOnStart: 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 = Config.options?.resources?.updateInterval ?? 3000;
|
|
}
|
|
}
|
|
|
|
FileView {
|
|
id: fileUptime
|
|
|
|
path: "/proc/uptime"
|
|
}
|
|
}
|