lock: add fetch + refactor os info

This commit is contained in:
2 * r + 2 * t 2025-08-11 15:14:04 +10:00
parent 92010400b0
commit 0771aad11e
7 changed files with 222 additions and 81 deletions

View file

@ -4,7 +4,7 @@ import qs.utils
import qs.config
StyledText {
text: Icons.osIcon
text: SysInfo.osIcon
font.pointSize: Appearance.font.size.smaller
font.family: Appearance.font.family.mono
color: Colours.palette.m3tertiary

View file

@ -113,15 +113,15 @@ Row {
spacing: Appearance.spacing.normal
InfoLine {
icon: Icons.osIcon
text: Icons.osName
icon: SysInfo.osIcon
text: SysInfo.osPrettyName || SysInfo.osName
colour: Colours.palette.m3primary
materialIcon: false
}
InfoLine {
icon: "select_window_2"
text: Quickshell.env("XDG_CURRENT_DESKTOP") || Quickshell.env("XDG_SESSION_DESKTOP")
text: SysInfo.wm
colour: Colours.palette.m3secondary
}

View file

@ -39,6 +39,8 @@ RowLayout {
radius: Appearance.rounding.small
color: Colours.tPalette.m3surfaceContainer
Fetch {}
}
StyledClippingRect {

102
modules/lock/Fetch.qml Normal file
View file

@ -0,0 +1,102 @@
import qs.components
import qs.services
import qs.config
import qs.utils
import Quickshell
import Quickshell.Widgets
import QtQuick
import QtQuick.Layouts
ColumnLayout {
id: root
anchors.fill: parent
anchors.margins: Appearance.padding.large * 2
spacing: Appearance.spacing.large * 2
RowLayout {
spacing: Appearance.spacing.normal
StyledRect {
implicitWidth: prompt.implicitWidth + Appearance.padding.normal * 2
implicitHeight: prompt.implicitHeight + Appearance.padding.normal * 2
color: Colours.palette.m3primary
radius: Appearance.rounding.small
MonoText {
id: prompt
anchors.centerIn: parent
text: ">"
color: Colours.palette.m3onPrimary
}
}
MonoText {
text: "caelestiafetch.sh"
}
}
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: Appearance.spacing.large * 2
IconImage {
Layout.fillHeight: true
source: Quickshell.iconPath(SysInfo.logo)
implicitSize: height
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: Appearance.spacing.normal
FetchText {
text: qsTr("OS : %1").arg(SysInfo.osPrettyName || SysInfo.osName)
}
FetchText {
text: qsTr("WM : %1").arg(SysInfo.wm)
}
FetchText {
text: qsTr("USER: %1").arg(SysInfo.user)
}
FetchText {
text: qsTr("SH : %1").arg(SysInfo.shell)
}
}
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
spacing: Appearance.spacing.large
Repeater {
model: 8
StyledRect {
required property int index
implicitWidth: implicitHeight
implicitHeight: Appearance.font.size.larger * 2
color: Colours.palette[`term${index}`]
radius: Appearance.rounding.small
}
}
}
component FetchText: MonoText {
font.pointSize: Appearance.font.size.larger
elide: Text.ElideRight
}
component MonoText: StyledText {
font.family: Appearance.font.family.mono
}
}

View file

@ -68,7 +68,7 @@ Singleton {
}
for (const [name, colour] of Object.entries(scheme.colours)) {
const propName = `m3${name}`;
const propName = name.startsWith("term") ? name : `m3${name}`;
if (colours.hasOwnProperty(propName))
colours[propName] = `#${colour}`;
}
@ -157,59 +157,75 @@ Singleton {
}
component M3Palette: QtObject {
property color m3primary_paletteKeyColor: "#7870AB"
property color m3secondary_paletteKeyColor: "#78748A"
property color m3tertiary_paletteKeyColor: "#976A7D"
property color m3neutral_paletteKeyColor: "#79767D"
property color m3neutral_variant_paletteKeyColor: "#797680"
property color m3background: "#141318"
property color m3onBackground: "#E5E1E9"
property color m3surface: "#141318"
property color m3surfaceDim: "#141318"
property color m3surfaceBright: "#3A383E"
property color m3surfaceContainerLowest: "#0E0D13"
property color m3surfaceContainerLow: "#1C1B20"
property color m3surfaceContainer: "#201F25"
property color m3surfaceContainerHigh: "#2B292F"
property color m3surfaceContainerHighest: "#35343A"
property color m3onSurface: "#E5E1E9"
property color m3surfaceVariant: "#48454E"
property color m3onSurfaceVariant: "#C9C5D0"
property color m3inverseSurface: "#E5E1E9"
property color m3inverseOnSurface: "#312F36"
property color m3outline: "#938F99"
property color m3outlineVariant: "#48454E"
property color m3primary_paletteKeyColor: "#a26387"
property color m3secondary_paletteKeyColor: "#8b6f7d"
property color m3tertiary_paletteKeyColor: "#9c6c53"
property color m3neutral_paletteKeyColor: "#7f7478"
property color m3neutral_variant_paletteKeyColor: "#827379"
property color m3background: "#181115"
property color m3onBackground: "#eddfe4"
property color m3surface: "#181115"
property color m3surfaceDim: "#181115"
property color m3surfaceBright: "#40373b"
property color m3surfaceContainerLowest: "#130c10"
property color m3surfaceContainerLow: "#211a1d"
property color m3surfaceContainer: "#251e21"
property color m3surfaceContainerHigh: "#30282b"
property color m3surfaceContainerHighest: "#3b3236"
property color m3onSurface: "#eddfe4"
property color m3surfaceVariant: "#504349"
property color m3onSurfaceVariant: "#d3c2c9"
property color m3inverseSurface: "#eddfe4"
property color m3inverseOnSurface: "#362e32"
property color m3outline: "#9c8d93"
property color m3outlineVariant: "#504349"
property color m3shadow: "#000000"
property color m3scrim: "#000000"
property color m3surfaceTint: "#C8BFFF"
property color m3primary: "#C8BFFF"
property color m3onPrimary: "#30285F"
property color m3primaryContainer: "#473F77"
property color m3onPrimaryContainer: "#E5DEFF"
property color m3inversePrimary: "#5F5791"
property color m3secondary: "#C9C3DC"
property color m3onSecondary: "#312E41"
property color m3secondaryContainer: "#484459"
property color m3onSecondaryContainer: "#E5DFF9"
property color m3tertiary: "#ECB8CD"
property color m3onTertiary: "#482536"
property color m3tertiaryContainer: "#B38397"
property color m3surfaceTint: "#fbb1d8"
property color m3primary: "#fbb1d8"
property color m3onPrimary: "#511d3e"
property color m3primaryContainer: "#6b3455"
property color m3onPrimaryContainer: "#ffd8ea"
property color m3inversePrimary: "#864b6e"
property color m3secondary: "#dfbecd"
property color m3onSecondary: "#402a36"
property color m3secondaryContainer: "#5a424f"
property color m3onSecondaryContainer: "#fcd9e9"
property color m3tertiary: "#f3ba9c"
property color m3onTertiary: "#4a2713"
property color m3tertiaryContainer: "#b8856a"
property color m3onTertiaryContainer: "#000000"
property color m3error: "#EA8DC1"
property color m3error: "#ffb4ab"
property color m3onError: "#690005"
property color m3errorContainer: "#93000A"
property color m3onErrorContainer: "#FFDAD6"
property color m3primaryFixed: "#E5DEFF"
property color m3primaryFixedDim: "#C8BFFF"
property color m3onPrimaryFixed: "#1B1149"
property color m3onPrimaryFixedVariant: "#473F77"
property color m3secondaryFixed: "#E5DFF9"
property color m3secondaryFixedDim: "#C9C3DC"
property color m3onSecondaryFixed: "#1C192B"
property color m3onSecondaryFixedVariant: "#484459"
property color m3tertiaryFixed: "#FFD8E7"
property color m3tertiaryFixedDim: "#ECB8CD"
property color m3onTertiaryFixed: "#301121"
property color m3onTertiaryFixedVariant: "#613B4C"
property color m3errorContainer: "#93000a"
property color m3onErrorContainer: "#ffdad6"
property color m3primaryFixed: "#ffd8ea"
property color m3primaryFixedDim: "#fbb1d8"
property color m3onPrimaryFixed: "#370728"
property color m3onPrimaryFixedVariant: "#6b3455"
property color m3secondaryFixed: "#fcd9e9"
property color m3secondaryFixedDim: "#dfbecd"
property color m3onSecondaryFixed: "#291520"
property color m3onSecondaryFixedVariant: "#58404c"
property color m3tertiaryFixed: "#ffdbca"
property color m3tertiaryFixedDim: "#f3ba9c"
property color m3onTertiaryFixed: "#311302"
property color m3onTertiaryFixedVariant: "#653d27"
property color term0: "#353434"
property color term1: "#fe45a7"
property color term2: "#ffbac0"
property color term3: "#ffdee3"
property color term4: "#b3a2d5"
property color term5: "#e491bd"
property color term6: "#ffba93"
property color term7: "#edd2d5"
property color term8: "#b29ea1"
property color term9: "#ff7db7"
property color term10: "#ffd2d5"
property color term11: "#fff1f2"
property color term12: "#babfdd"
property color term13: "#f3a9cd"
property color term14: "#ffd1c0"
property color term15: "#ffffff"
}
}

View file

@ -1,7 +1,6 @@
pragma Singleton
import Quickshell
import Quickshell.Io
import Quickshell.Services.Notifications
Singleton {
@ -143,9 +142,6 @@ Singleton {
Office: "content_paste"
})
property string osIcon: ""
property string osName
function getAppIcon(name: string, fallback: string): string {
const icon = DesktopEntries.heuristicLookup(name)?.icon;
if (fallback !== "undefined")
@ -232,26 +228,4 @@ Singleton {
return "volume_down";
return "volume_mute";
}
FileView {
path: "/etc/os-release"
onLoaded: {
const lines = text().split("\n");
let osId = lines.find(l => l.startsWith("ID="))?.split("=")[1].replace(/"/g, "");
if (root.osIcons.hasOwnProperty(osId))
root.osIcon = root.osIcons[osId];
else {
const osIdLike = lines.find(l => l.startsWith("ID_LIKE="))?.split("=")[1].replace(/"/g, "");
if (osIdLike)
for (const id of osIdLike.split(" "))
if (root.osIcons.hasOwnProperty(id))
return root.osIcon = root.osIcons[id];
}
let nameLine = lines.find(l => l.startsWith("PRETTY_NAME="));
if (!nameLine)
nameLine = lines.find(l => l.startsWith("NAME="));
root.osName = nameLine.split("=")[1].replace(/"/g, "");
}
}
}

47
utils/SysInfo.qml Normal file
View file

@ -0,0 +1,47 @@
pragma Singleton
import Quickshell
import Quickshell.Io
Singleton {
id: root
property string osName
property string osPrettyName
property string osId
property list<string> osIdLike
property string logo
property string osIcon: ""
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
path: "/etc/os-release"
onLoaded: {
const lines = text().split("\n");
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.logo = fd("LOGO");
const osIcons = Icons.osIcons;
if (osIcons.hasOwnProperty(root.osId)) {
root.osIcon = osIcons[root.osId];
} else {
for (const id of root.osIdLike) {
if (osIcons.hasOwnProperty(id)) {
root.osIcon = osIcons[id];
}
}
}
}
}
}