formatter
This commit is contained in:
+63
-61
@@ -6,79 +6,81 @@ import Quickshell.Io
|
||||
import QtQuick
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
id: root
|
||||
|
||||
property string osName
|
||||
property string osPrettyName
|
||||
property string osId
|
||||
property list<string> osIdLike
|
||||
property string osLogo
|
||||
property bool isDefaultLogo: true
|
||||
property bool isDefaultLogo: true
|
||||
property string osId
|
||||
property list<string> osIdLike
|
||||
property string osLogo
|
||||
property string osName
|
||||
property string osPrettyName
|
||||
readonly property string shell: Quickshell.env("SHELL").split("/").pop()
|
||||
property string uptime
|
||||
readonly property string user: Quickshell.env("USER")
|
||||
readonly property string wm: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP")
|
||||
|
||||
property string uptime
|
||||
readonly property string user: Quickshell.env("USER")
|
||||
readonly property string wm: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP")
|
||||
readonly property string shell: Quickshell.env("SHELL").split("/").pop()
|
||||
FileView {
|
||||
id: osRelease
|
||||
|
||||
FileView {
|
||||
id: osRelease
|
||||
path: "/etc/os-release"
|
||||
|
||||
path: "/etc/os-release"
|
||||
onLoaded: {
|
||||
const lines = text().split("\n");
|
||||
onLoaded: {
|
||||
const lines = text().split("\n");
|
||||
|
||||
const fd = key => lines.find(l => l.startsWith(`${key}=`))?.split("=")[1].replace(/"/g, "") ?? "";
|
||||
const fd = key => lines.find(l => l.startsWith(`${key}=`))?.split("=")[1].replace(/"/g, "") ?? "";
|
||||
|
||||
root.osName = fd("NAME");
|
||||
root.osPrettyName = fd("PRETTY_NAME");
|
||||
root.osId = fd("ID");
|
||||
root.osIdLike = fd("ID_LIKE").split(" ");
|
||||
root.osName = fd("NAME");
|
||||
root.osPrettyName = fd("PRETTY_NAME");
|
||||
root.osId = fd("ID");
|
||||
root.osIdLike = fd("ID_LIKE").split(" ");
|
||||
|
||||
const logo = Quickshell.iconPath(fd("LOGO"), true);
|
||||
if (Config.general.logo) {
|
||||
root.osLogo = Quickshell.iconPath(Config.general.logo, true) || "file://" + Paths.absolutePath(Config.general.logo);
|
||||
root.isDefaultLogo = false;
|
||||
} else if (logo) {
|
||||
root.osLogo = logo;
|
||||
root.isDefaultLogo = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
const logo = Quickshell.iconPath(fd("LOGO"), true);
|
||||
if (Config.general.logo) {
|
||||
root.osLogo = Quickshell.iconPath(Config.general.logo, true) || "file://" + Paths.absolutePath(Config.general.logo);
|
||||
root.isDefaultLogo = false;
|
||||
} else if (logo) {
|
||||
root.osLogo = logo;
|
||||
root.isDefaultLogo = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Config.general
|
||||
Connections {
|
||||
function onLogoChanged(): void {
|
||||
osRelease.reload();
|
||||
}
|
||||
|
||||
function onLogoChanged(): void {
|
||||
osRelease.reload();
|
||||
}
|
||||
}
|
||||
target: Config.general
|
||||
}
|
||||
|
||||
Timer {
|
||||
running: true
|
||||
repeat: true
|
||||
interval: 15000
|
||||
onTriggered: fileUptime.reload()
|
||||
}
|
||||
Timer {
|
||||
interval: 15000
|
||||
repeat: true
|
||||
running: true
|
||||
|
||||
FileView {
|
||||
id: fileUptime
|
||||
onTriggered: fileUptime.reload()
|
||||
}
|
||||
|
||||
path: "/proc/uptime"
|
||||
onLoaded: {
|
||||
const up = parseInt(text().split(" ")[0] ?? 0);
|
||||
FileView {
|
||||
id: fileUptime
|
||||
|
||||
const days = Math.floor(up / 86400);
|
||||
const hours = Math.floor((up % 86400) / 3600);
|
||||
const minutes = Math.floor((up % 3600) / 60);
|
||||
path: "/proc/uptime"
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user