Merge branch 'main' of github.com:noctalia-dev/noctalia-shell

This commit is contained in:
LemmyCook 2025-09-14 15:06:45 -04:00
commit 0682315c9d
2 changed files with 66 additions and 34 deletions

View file

@ -37,16 +37,14 @@ Item {
readonly property bool showNetworkStats: (widgetSettings.showNetworkStats !== undefined) ? widgetSettings.showNetworkStats : widgetMetadata.showNetworkStats readonly property bool showNetworkStats: (widgetSettings.showNetworkStats !== undefined) ? widgetSettings.showNetworkStats : widgetMetadata.showNetworkStats
readonly property bool showDiskUsage: (widgetSettings.showDiskUsage !== undefined) ? widgetSettings.showDiskUsage : widgetMetadata.showDiskUsage readonly property bool showDiskUsage: (widgetSettings.showDiskUsage !== undefined) ? widgetSettings.showDiskUsage : widgetMetadata.showDiskUsage
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : Math.round(horizontalLayout.implicitWidth + Style.marginS * 2 * scaling) implicitWidth: backgroundContainer.width
implicitHeight: backgroundContainer.height
implicitHeight: (barPosition === "left" || barPosition === "right") ? Math.round(verticalLayout.implicitHeight + Style.marginS * 2 * scaling) : Math.round(Style.barHeight * scaling)
Rectangle { Rectangle {
id: backgroundContainer id: backgroundContainer
anchors.centerIn: parent anchors.centerIn: parent
width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : parent.width width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : Math.round(horizontalLayout.implicitWidth + Style.marginS * 2 * scaling)
height: (barPosition === "left" || barPosition === "right") ? parent.height : Math.round(Style.capsuleHeight * scaling) height: (barPosition === "left" || barPosition === "right") ? Math.round(verticalLayout.implicitHeight + Style.marginS * 2 * scaling) : Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling) radius: Math.round(Style.radiusM * scaling)
color: Color.mSurfaceVariant color: Color.mSurfaceVariant
@ -251,7 +249,6 @@ Item {
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
visible: barPosition === "left" || barPosition === "right" visible: barPosition === "left" || barPosition === "right"
// CPU Usage Component // CPU Usage Component
Item { Item {
Layout.preferredHeight: Math.round(Style.capsuleHeight * scaling) Layout.preferredHeight: Math.round(Style.capsuleHeight * scaling)
@ -279,7 +276,6 @@ Item {
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
} }
@ -295,7 +291,6 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
spacing: Style.marginXXS * scaling spacing: Style.marginXXS * scaling
NText { NText {
text: `${SystemStatService.cpuTemp}°` text: `${SystemStatService.cpuTemp}°`
font.family: Settings.data.ui.fontFixed font.family: Settings.data.ui.fontFixed
@ -312,7 +307,6 @@ Item {
font.pointSize: Style.fontSizeXS * scaling font.pointSize: Style.fontSizeXS * scaling
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
} }
} }

View file

@ -3,6 +3,7 @@ pragma Singleton
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Quickshell import Quickshell
import Quickshell.Io
import qs.Commons import qs.Commons
Singleton { Singleton {
@ -12,11 +13,17 @@ Singleton {
property ListModel monospaceFonts: ListModel {} property ListModel monospaceFonts: ListModel {}
property ListModel displayFonts: ListModel {} property ListModel displayFonts: ListModel {}
property bool fontsLoaded: false property bool fontsLoaded: false
property var fontconfigMonospaceFonts: []
// ------------------------------------------- // -------------------------------------------
function init() { function init() {
Logger.log("Font", "Service started") Logger.log("Font", "Service started")
loadSystemFonts() loadFontconfigMonospaceFonts()
}
function loadFontconfigMonospaceFonts() {
fontconfigProcess.command = ["fc-list", ":mono", "family"]
fontconfigProcess.running = true
} }
function loadSystemFonts() { function loadSystemFonts() {
@ -57,13 +64,11 @@ Singleton {
sortModel(displayFonts) sortModel(displayFonts)
if (monospaceFonts.count === 0) { if (monospaceFonts.count === 0) {
Logger.log("Font", "No monospace fonts detected, adding fallbacks") addFallbackFonts(monospaceFonts, ["DejaVu Sans Mono"])
addFallbackFonts(monospaceFonts, ["DejaVu Sans Mono", "Liberation Mono", "Courier New", "Courier", "Monaco", "Consolas", "Lucida Console", "Monaco", "Andale Mono"])
} }
if (displayFonts.count === 0) { if (displayFonts.count === 0) {
Logger.log("Font", "No display fonts detected, adding fallbacks") addFallbackFonts(displayFonts, ["Inter", "Roboto", "DejaVu Sans"])
addFallbackFonts(displayFonts, ["Inter", "Roboto", "Open Sans", "Arial", "Helvetica", "Verdana", "Segoe UI", "SF Pro Display", "Ubuntu", "Noto Sans"])
} }
fontsLoaded = true fontsLoaded = true
@ -71,29 +76,30 @@ Singleton {
} }
function isMonospaceFont(fontName) { function isMonospaceFont(fontName) {
var patterns = ["mono", "monospace", "fixed", "console", "terminal", "typewriter", "courier", "dejavu", "liberation", "source code", "fira code", "jetbrains", "cascadia", "hack", "inconsolata", "roboto mono", "ubuntu mono", "menlo", "consolas", "monaco", "andale mono"] // First, check if fontconfig detected this as monospace
var lowerFontName = fontName.toLowerCase() if (fontconfigMonospaceFonts.indexOf(fontName) !== -1) {
for (var i = 0; i < patterns.length; i++) {
if (lowerFontName.includes(patterns[i]))
return true return true
} }
var commonFonts = ["DejaVu Sans Mono", "Liberation Mono", "Source Code Pro", "Fira Code", "JetBrains Mono", "Cascadia Code", "Hack", "Inconsolata", "Roboto Mono", "Ubuntu Mono", "Menlo", "Consolas", "Monaco", "Andale Mono", "Courier New", "Courier", "Lucida Console", "Monaco", "MS Gothic", "MS Mincho"] // Minimal fallback: only check for basic monospace patterns
return commonFonts.includes(fontName) var lowerFontName = fontName.toLowerCase()
if (lowerFontName.includes("mono") || lowerFontName.includes("monospace")) {
return true
}
return false
} }
function isDisplayFont(fontName) { function isDisplayFont(fontName) {
var patterns = ["display", "headline", "title", "hero", "showcase", "brand", "inter", "roboto", "open sans", "lato", "montserrat", "poppins", "raleway", "nunito", "source sans", "ubuntu", "noto sans", "work sans", "dm sans", "manrope", "plus jakarta", "figtree"] // Minimal fallback: only check for basic display patterns
var lowerFontName = fontName.toLowerCase() var lowerFontName = fontName.toLowerCase()
if (lowerFontName.includes("display") || lowerFontName.includes("headline") || lowerFontName.includes("title")) {
for (var i = 0; i < patterns.length; i++) {
if (lowerFontName.includes(patterns[i]))
return true return true
} }
var commonFonts = ["Inter", "Roboto", "Open Sans", "Lato", "Montserrat", "Poppins", "Raleway", "Nunito", "Source Sans Pro", "Ubuntu", "Noto Sans", "Work Sans", "DM Sans", "Manrope", "Plus Jakarta Sans", "Figtree", "SF Pro Display", "Segoe UI", "Arial", "Helvetica", "Verdana"] // Essential fallback fonts only
return commonFonts.includes(fontName) var essentialFonts = ["Inter", "Roboto", "DejaVu Sans"]
return essentialFonts.includes(fontName)
} }
function sortModel(model) { function sortModel(model) {
@ -153,4 +159,36 @@ Singleton {
return results return results
} }
// Process for fontconfig commands
Process {
id: fontconfigProcess
running: false
stdout: StdioCollector {
onStreamFinished: {
if (this.text !== "") {
var lines = this.text.split('\n')
fontconfigMonospaceFonts = []
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim()
if (line && line !== "") {
if (fontconfigMonospaceFonts.indexOf(line) === -1) {
fontconfigMonospaceFonts.push(line)
}
}
}
}
loadSystemFonts()
}
}
onExited: function (exitCode, exitStatus) {
if (exitCode !== 0) {
fontconfigMonospaceFonts = []
}
loadSystemFonts()
}
}
} }