lock/fetch: shell -> uptime + no qsTr
This commit is contained in:
parent
efa806b8d6
commit
1e1cdd95c1
3 changed files with 36 additions and 35 deletions
|
|
@ -4,7 +4,6 @@ import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
|
@ -129,37 +128,8 @@ Row {
|
||||||
id: uptime
|
id: uptime
|
||||||
|
|
||||||
icon: "timer"
|
icon: "timer"
|
||||||
text: qsTr("Loading uptime...")
|
text: qsTr("up %1").arg(SysInfo.uptime)
|
||||||
colour: Colours.palette.m3tertiary
|
colour: Colours.palette.m3tertiary
|
||||||
|
|
||||||
Timer {
|
|
||||||
running: true
|
|
||||||
repeat: true
|
|
||||||
interval: 15000
|
|
||||||
onTriggered: fileUptime.reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
FileView {
|
|
||||||
id: fileUptime
|
|
||||||
|
|
||||||
path: "/proc/uptime"
|
|
||||||
onLoaded: {
|
|
||||||
const up = parseInt(text().split(" ")[0] ?? 0);
|
|
||||||
|
|
||||||
const days = Math.floor(up / 86400);
|
|
||||||
const hours = Math.floor((up % 86400) / 3600);
|
|
||||||
const minutes = Math.floor((up % 3600) / 60);
|
|
||||||
|
|
||||||
let str = "";
|
|
||||||
if (days > 0)
|
|
||||||
str += `${days} day${days === 1 ? "" : "s"}`;
|
|
||||||
if (hours > 0)
|
|
||||||
str += `${str ? ", " : ""}${hours} hour${hours === 1 ? "" : "s"}`;
|
|
||||||
if (minutes > 0 || !str)
|
|
||||||
str += `${str ? ", " : ""}${minutes} minute${minutes === 1 ? "" : "s"}`;
|
|
||||||
uptime.text = qsTr("up %1").arg(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,19 +87,19 @@ ColumnLayout {
|
||||||
spacing: Appearance.spacing.normal
|
spacing: Appearance.spacing.normal
|
||||||
|
|
||||||
FetchText {
|
FetchText {
|
||||||
text: qsTr("OS : %1").arg(SysInfo.osPrettyName || SysInfo.osName)
|
text: `OS : ${SysInfo.osPrettyName || SysInfo.osName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
FetchText {
|
FetchText {
|
||||||
text: qsTr("WM : %1").arg(SysInfo.wm)
|
text: `WM : ${SysInfo.wm}`
|
||||||
}
|
}
|
||||||
|
|
||||||
FetchText {
|
FetchText {
|
||||||
text: qsTr("USER: %1").arg(SysInfo.user)
|
text: `USER: ${SysInfo.user}`
|
||||||
}
|
}
|
||||||
|
|
||||||
FetchText {
|
FetchText {
|
||||||
text: qsTr("SH : %1").arg(SysInfo.shell)
|
text: `UP : ${SysInfo.uptime}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ pragma Singleton
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -13,6 +14,7 @@ Singleton {
|
||||||
property string logo
|
property string logo
|
||||||
property string osIcon: ""
|
property string osIcon: ""
|
||||||
|
|
||||||
|
property string uptime
|
||||||
readonly property string user: Quickshell.env("USER")
|
readonly property string user: Quickshell.env("USER")
|
||||||
readonly property string wm: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP")
|
readonly property string wm: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP")
|
||||||
readonly property string shell: Quickshell.env("SHELL").split("/").pop()
|
readonly property string shell: Quickshell.env("SHELL").split("/").pop()
|
||||||
|
|
@ -44,4 +46,33 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
interval: 15000
|
||||||
|
onTriggered: fileUptime.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: fileUptime
|
||||||
|
|
||||||
|
path: "/proc/uptime"
|
||||||
|
onLoaded: {
|
||||||
|
const up = parseInt(text().split(" ")[0] ?? 0);
|
||||||
|
|
||||||
|
const days = Math.floor(up / 86400);
|
||||||
|
const hours = Math.floor((up % 86400) / 3600);
|
||||||
|
const minutes = Math.floor((up % 3600) / 60);
|
||||||
|
|
||||||
|
let str = "";
|
||||||
|
if (days > 0)
|
||||||
|
str += `${days} day${days === 1 ? "" : "s"}`;
|
||||||
|
if (hours > 0)
|
||||||
|
str += `${str ? ", " : ""}${hours} hour${hours === 1 ? "" : "s"}`;
|
||||||
|
if (minutes > 0 || !str)
|
||||||
|
str += `${str ? ", " : ""}${minutes} minute${minutes === 1 ? "" : "s"}`;
|
||||||
|
root.uptime = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue