forked from Shinonome/dots-hyprland
49 lines
1.5 KiB
QML
49 lines
1.5 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
import qs
|
|
import qs.modules.common
|
|
import qs.modules.common.functions
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
/**
|
|
* A nice wrapper for date and time strings.
|
|
*/
|
|
Singleton {
|
|
id: root
|
|
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 {
|
|
interval: 10
|
|
running: true
|
|
repeat: true
|
|
onTriggered: {
|
|
fileUptime.reload();
|
|
const textUptime = fileUptime.text();
|
|
const uptimeSeconds = Number(textUptime.split(" ")[0] ?? 0);
|
|
root.uptime = DateUtils.formatDuration(uptimeSeconds)
|
|
interval = Config.options?.resources?.updateInterval ?? 3000;
|
|
}
|
|
}
|
|
|
|
FileView {
|
|
id: fileUptime
|
|
|
|
path: "/proc/uptime"
|
|
}
|
|
}
|