mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
migrate to dankgop monitoring
This commit is contained in:
35
.gitignore
vendored
35
.gitignore
vendored
@@ -63,4 +63,37 @@ CLAUDE-temp.md
|
||||
niri-colors.generated.kdl
|
||||
ghostty-colors.generated.conf
|
||||
|
||||
result
|
||||
result
|
||||
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Code coverage profiles and other test artifacts
|
||||
*.out
|
||||
coverage.*
|
||||
*.coverprofile
|
||||
profile.cov
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
# env file
|
||||
.env
|
||||
|
||||
# Editor/IDE
|
||||
# .idea/
|
||||
# .vscode/
|
||||
|
||||
@@ -20,6 +20,7 @@ Singleton {
|
||||
property int selectedGpuIndex: 0
|
||||
property bool nvidiaGpuTempEnabled: false
|
||||
property bool nonNvidiaGpuTempEnabled: false
|
||||
property var enabledGpuPciIds: []
|
||||
|
||||
Component.onCompleted: {
|
||||
loadSettings()
|
||||
@@ -43,6 +44,7 @@ Singleton {
|
||||
selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0
|
||||
nvidiaGpuTempEnabled = settings.nvidiaGpuTempEnabled !== undefined ? settings.nvidiaGpuTempEnabled : false
|
||||
nonNvidiaGpuTempEnabled = settings.nonNvidiaGpuTempEnabled !== undefined ? settings.nonNvidiaGpuTempEnabled : false
|
||||
enabledGpuPciIds = settings.enabledGpuPciIds !== undefined ? settings.enabledGpuPciIds : []
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -59,7 +61,8 @@ Singleton {
|
||||
"pinnedApps": pinnedApps,
|
||||
"selectedGpuIndex": selectedGpuIndex,
|
||||
"nvidiaGpuTempEnabled": nvidiaGpuTempEnabled,
|
||||
"nonNvidiaGpuTempEnabled": nonNvidiaGpuTempEnabled
|
||||
"nonNvidiaGpuTempEnabled": nonNvidiaGpuTempEnabled,
|
||||
"enabledGpuPciIds": enabledGpuPciIds
|
||||
}, null, 2))
|
||||
}
|
||||
|
||||
@@ -139,6 +142,11 @@ Singleton {
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setEnabledGpuPciIds(pciIds) {
|
||||
enabledGpuPciIds = pciIds
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: settingsFile
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ Singleton {
|
||||
property bool showCpuTemp: true
|
||||
property bool showGpuTemp: true
|
||||
property int selectedGpuIndex: 0
|
||||
property var enabledGpuPciIds: []
|
||||
property bool showSystemTray: true
|
||||
property bool showClock: true
|
||||
property bool showNotificationButton: true
|
||||
@@ -187,6 +188,7 @@ Singleton {
|
||||
showCpuTemp = settings.showCpuTemp !== undefined ? settings.showCpuTemp : true
|
||||
showGpuTemp = settings.showGpuTemp !== undefined ? settings.showGpuTemp : true
|
||||
selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0
|
||||
enabledGpuPciIds = settings.enabledGpuPciIds !== undefined ? settings.enabledGpuPciIds : []
|
||||
showSystemTray = settings.showSystemTray !== undefined ? settings.showSystemTray : true
|
||||
showClock = settings.showClock !== undefined ? settings.showClock : true
|
||||
showNotificationButton = settings.showNotificationButton
|
||||
@@ -291,6 +293,7 @@ Singleton {
|
||||
"showCpuTemp": showCpuTemp,
|
||||
"showGpuTemp": showGpuTemp,
|
||||
"selectedGpuIndex": selectedGpuIndex,
|
||||
"enabledGpuPciIds": enabledGpuPciIds,
|
||||
"showSystemTray": showSystemTray,
|
||||
"showClock": showClock,
|
||||
"showNotificationButton": showNotificationButton,
|
||||
@@ -453,6 +456,11 @@ Singleton {
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setEnabledGpuPciIds(pciIds) {
|
||||
enabledGpuPciIds = pciIds
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setShowSystemTray(enabled) {
|
||||
showSystemTray = enabled
|
||||
saveSettings()
|
||||
@@ -508,6 +516,7 @@ Singleton {
|
||||
var enabled = typeof order[i] === "string" ? true : order[i].enabled
|
||||
var size = typeof order[i] === "string" ? undefined : order[i].size
|
||||
var selectedGpuIndex = typeof order[i] === "string" ? undefined : order[i].selectedGpuIndex
|
||||
var pciId = typeof order[i] === "string" ? undefined : order[i].pciId
|
||||
|
||||
var item = {
|
||||
"widgetId": widgetId,
|
||||
@@ -519,6 +528,9 @@ Singleton {
|
||||
if (selectedGpuIndex !== undefined) {
|
||||
item.selectedGpuIndex = selectedGpuIndex
|
||||
}
|
||||
if (pciId !== undefined) {
|
||||
item.pciId = pciId
|
||||
}
|
||||
listModel.append(item)
|
||||
}
|
||||
// Emit signal to notify widgets that data has changed
|
||||
@@ -528,7 +540,7 @@ Singleton {
|
||||
function resetTopBarWidgetsToDefault() {
|
||||
var defaultLeft = ["launcherButton", "workspaceSwitcher", "focusedWindow"]
|
||||
var defaultCenter = ["music", "clock", "weather"]
|
||||
var defaultRight = ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"]
|
||||
var defaultRight = ["systemTray", "clipboard", "notificationButton", "battery", "controlCenterButton"]
|
||||
|
||||
topBarLeftWidgets = defaultLeft
|
||||
topBarCenterWidgets = defaultCenter
|
||||
|
||||
@@ -18,6 +18,10 @@ DankModal {
|
||||
property var tabNames: ["Processes", "Performance", "System"]
|
||||
|
||||
function show() {
|
||||
if (!DankgopService.dankgopAvailable) {
|
||||
console.warn("ProcessListModal: dankgop is not available")
|
||||
return
|
||||
}
|
||||
processListModal.visible = true
|
||||
UserInfoService.getUptime()
|
||||
}
|
||||
@@ -29,6 +33,10 @@ DankModal {
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
if (!DankgopService.dankgopAvailable) {
|
||||
console.warn("ProcessListModal: dankgop is not available")
|
||||
return
|
||||
}
|
||||
if (processListModal.visible)
|
||||
hide()
|
||||
else
|
||||
@@ -44,9 +52,6 @@ DankModal {
|
||||
enableShadow: true
|
||||
onBackgroundClicked: hide()
|
||||
|
||||
Ref {
|
||||
service: SysMonitorService
|
||||
}
|
||||
|
||||
Component {
|
||||
id: processesTabComponent
|
||||
@@ -92,10 +97,52 @@ DankModal {
|
||||
}
|
||||
}
|
||||
|
||||
// Show error message when dankgop is not available
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: 400
|
||||
height: 200
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.errorBackground
|
||||
border.color: Theme.error
|
||||
border.width: 2
|
||||
visible: !DankgopService.dankgopAvailable
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingL
|
||||
|
||||
DankIcon {
|
||||
name: "error"
|
||||
size: 48
|
||||
color: Theme.error
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "System Monitor Unavailable"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Bold
|
||||
color: Theme.error
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "The 'dankgop' tool is required for system monitoring.\nPlease install dankgop to use this feature."
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
spacing: Theme.spacingL
|
||||
visible: DankgopService.dankgopAvailable
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
@@ -233,7 +280,7 @@ DankModal {
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
active: currentTab === 0
|
||||
active: processListModal.visible && currentTab === 0
|
||||
visible: currentTab === 0
|
||||
opacity: currentTab === 0 ? 1 : 0
|
||||
sourceComponent: processesTabComponent
|
||||
@@ -251,7 +298,7 @@ DankModal {
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
active: currentTab === 1
|
||||
active: processListModal.visible && currentTab === 1
|
||||
visible: currentTab === 1
|
||||
opacity: currentTab === 1 ? 1 : 0
|
||||
sourceComponent: performanceTabComponent
|
||||
@@ -269,7 +316,7 @@ DankModal {
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingS
|
||||
active: currentTab === 2
|
||||
active: processListModal.visible && currentTab === 2
|
||||
visible: currentTab === 2
|
||||
opacity: currentTab === 2 ? 1 : 0
|
||||
sourceComponent: systemTabComponent
|
||||
|
||||
@@ -13,7 +13,7 @@ Rectangle {
|
||||
border.width: 1
|
||||
|
||||
Ref {
|
||||
service: SysMonitorService
|
||||
service: DankgopService
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -36,7 +36,7 @@ Rectangle {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.hostname
|
||||
text: DankgopService.hostname
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
@@ -45,7 +45,7 @@ Rectangle {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.distribution + " • " + SysMonitorService.architecture
|
||||
text: DankgopService.distribution + " • " + DankgopService.architecture
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.7)
|
||||
@@ -74,7 +74,7 @@ Rectangle {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "Load: " + SysMonitorService.loadAverage
|
||||
text: "Load: " + DankgopService.loadAverage
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
width: parent.width
|
||||
@@ -82,8 +82,8 @@ Rectangle {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.processCount + " proc, "
|
||||
+ SysMonitorService.threadCount + " threads"
|
||||
text: DankgopService.processCount + " proc, "
|
||||
+ DankgopService.threadCount + " threads"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.8)
|
||||
|
||||
@@ -28,10 +28,10 @@ Column {
|
||||
anchors.fill: parent
|
||||
spacing: Theme.spacingM
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["cpu", "memory", "network", "disk"])
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["cpu", "memory", "network", "disk"])
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -71,7 +71,7 @@ Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalCpuUsage.toFixed(1) + "%"
|
||||
text: DankgopService.cpuUsage.toFixed(1) + "%"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
color: Theme.primary
|
||||
@@ -85,7 +85,7 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.cpuCount + " cores"
|
||||
text: DankgopService.cpuCores + " cores"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -104,7 +104,7 @@ Column {
|
||||
spacing: 6
|
||||
|
||||
Repeater {
|
||||
model: SysMonitorService.perCoreCpuUsage
|
||||
model: DankgopService.perCoreCpuUsage
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -193,9 +193,9 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.formatSystemMemory(
|
||||
SysMonitorService.usedMemoryKB) + " / " + SysMonitorService.formatSystemMemory(
|
||||
SysMonitorService.totalMemoryKB)
|
||||
text: DankgopService.formatSystemMemory(
|
||||
DankgopService.usedMemoryKB) + " / " + DankgopService.formatSystemMemory(
|
||||
DankgopService.totalMemoryKB)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
@@ -218,15 +218,15 @@ Column {
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||
|
||||
Rectangle {
|
||||
width: SysMonitorService.totalMemoryKB
|
||||
> 0 ? parent.width * (SysMonitorService.usedMemoryKB
|
||||
/ SysMonitorService.totalMemoryKB) : 0
|
||||
width: DankgopService.totalMemoryKB
|
||||
> 0 ? parent.width * (DankgopService.usedMemoryKB
|
||||
/ DankgopService.totalMemoryKB) : 0
|
||||
height: parent.height
|
||||
radius: parent.radius
|
||||
color: {
|
||||
const usage = SysMonitorService.totalMemoryKB
|
||||
> 0 ? (SysMonitorService.usedMemoryKB
|
||||
/ SysMonitorService.totalMemoryKB) : 0
|
||||
const usage = DankgopService.totalMemoryKB
|
||||
> 0 ? (DankgopService.usedMemoryKB
|
||||
/ DankgopService.totalMemoryKB) : 0
|
||||
if (usage > 0.9)
|
||||
return Theme.error
|
||||
|
||||
@@ -245,9 +245,9 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalMemoryKB
|
||||
> 0 ? ((SysMonitorService.usedMemoryKB
|
||||
/ SysMonitorService.totalMemoryKB) * 100).toFixed(
|
||||
text: DankgopService.totalMemoryKB
|
||||
> 0 ? ((DankgopService.usedMemoryKB
|
||||
/ DankgopService.totalMemoryKB) * 100).toFixed(
|
||||
1) + "% used" : "No data"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
@@ -272,11 +272,11 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalSwapKB
|
||||
> 0 ? SysMonitorService.formatSystemMemory(
|
||||
SysMonitorService.usedSwapKB) + " / "
|
||||
+ SysMonitorService.formatSystemMemory(
|
||||
SysMonitorService.totalSwapKB) : "No swap configured"
|
||||
text: DankgopService.totalSwapKB
|
||||
> 0 ? DankgopService.formatSystemMemory(
|
||||
DankgopService.usedSwapKB) + " / "
|
||||
+ DankgopService.formatSystemMemory(
|
||||
DankgopService.totalSwapKB) : "No swap configured"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
@@ -299,17 +299,17 @@ Column {
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||
|
||||
Rectangle {
|
||||
width: SysMonitorService.totalSwapKB
|
||||
> 0 ? parent.width * (SysMonitorService.usedSwapKB
|
||||
/ SysMonitorService.totalSwapKB) : 0
|
||||
width: DankgopService.totalSwapKB
|
||||
> 0 ? parent.width * (DankgopService.usedSwapKB
|
||||
/ DankgopService.totalSwapKB) : 0
|
||||
height: parent.height
|
||||
radius: parent.radius
|
||||
color: {
|
||||
if (!SysMonitorService.totalSwapKB)
|
||||
if (!DankgopService.totalSwapKB)
|
||||
return Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.3)
|
||||
|
||||
const usage = SysMonitorService.usedSwapKB / SysMonitorService.totalSwapKB
|
||||
const usage = DankgopService.usedSwapKB / DankgopService.totalSwapKB
|
||||
if (usage > 0.9)
|
||||
return Theme.error
|
||||
|
||||
@@ -328,9 +328,9 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalSwapKB
|
||||
> 0 ? ((SysMonitorService.usedSwapKB
|
||||
/ SysMonitorService.totalSwapKB) * 100).toFixed(
|
||||
text: DankgopService.totalSwapKB
|
||||
> 0 ? ((DankgopService.usedSwapKB
|
||||
/ DankgopService.totalSwapKB) * 100).toFixed(
|
||||
1) + "% used" : "Not available"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
@@ -381,9 +381,9 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.networkRxRate
|
||||
text: DankgopService.networkRxRate
|
||||
> 0 ? formatNetworkSpeed(
|
||||
SysMonitorService.networkRxRate) : "0 B/s"
|
||||
DankgopService.networkRxRate) : "0 B/s"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
color: Theme.surfaceText
|
||||
@@ -400,9 +400,9 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.networkTxRate
|
||||
text: DankgopService.networkTxRate
|
||||
> 0 ? formatNetworkSpeed(
|
||||
SysMonitorService.networkTxRate) : "0 B/s"
|
||||
DankgopService.networkTxRate) : "0 B/s"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
color: Theme.surfaceText
|
||||
@@ -448,7 +448,7 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: formatDiskSpeed(SysMonitorService.diskReadRate)
|
||||
text: formatDiskSpeed(DankgopService.diskReadRate)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
color: Theme.surfaceText
|
||||
@@ -465,7 +465,7 @@ Column {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: formatDiskSpeed(SysMonitorService.diskWriteRate)
|
||||
text: formatDiskSpeed(DankgopService.diskWriteRate)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Bold
|
||||
color: Theme.surfaceText
|
||||
|
||||
@@ -59,7 +59,7 @@ Rectangle {
|
||||
DankIcon {
|
||||
id: processIcon
|
||||
|
||||
name: SysMonitorService.getProcessIcon(process ? process.command : "")
|
||||
name: DankgopService.getProcessIcon(process ? process.command : "")
|
||||
size: Theme.iconSize - 4
|
||||
color: {
|
||||
if (process && process.cpu > 80)
|
||||
@@ -110,7 +110,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.formatCpuUsage(process ? process.cpu : 0)
|
||||
text: DankgopService.formatCpuUsage(process ? process.cpu : 0)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
@@ -149,7 +149,7 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.formatMemoryUsage(
|
||||
text: DankgopService.formatMemoryUsage(
|
||||
process ? process.memoryKB : 0)
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
|
||||
@@ -57,7 +57,7 @@ PanelWindow {
|
||||
color: "transparent"
|
||||
|
||||
Ref {
|
||||
service: SysMonitorService
|
||||
service: DankgopService
|
||||
}
|
||||
|
||||
anchors {
|
||||
|
||||
@@ -10,10 +10,10 @@ Column {
|
||||
property var contextMenu: null
|
||||
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["processes"])
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["processes"])
|
||||
}
|
||||
|
||||
Item {
|
||||
@@ -39,9 +39,9 @@ Column {
|
||||
text: "Process"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: SysMonitorService.sortBy === "name" ? Font.Bold : Font.Medium
|
||||
font.weight: DankgopService.sortBy === "name" ? Font.Bold : Font.Medium
|
||||
color: Theme.surfaceText
|
||||
opacity: SysMonitorService.sortBy === "name" ? 1 : 0.7
|
||||
opacity: DankgopService.sortBy === "name" ? 1 : 0.7
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
SysMonitorService.setSortBy("name")
|
||||
DankgopService.setSortBy("name")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ Column {
|
||||
text: "CPU"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: SysMonitorService.sortBy === "cpu" ? Font.Bold : Font.Medium
|
||||
font.weight: DankgopService.sortBy === "cpu" ? Font.Bold : Font.Medium
|
||||
color: Theme.surfaceText
|
||||
opacity: SysMonitorService.sortBy === "cpu" ? 1 : 0.7
|
||||
opacity: DankgopService.sortBy === "cpu" ? 1 : 0.7
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
SysMonitorService.setSortBy("cpu")
|
||||
DankgopService.setSortBy("cpu")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +119,9 @@ Column {
|
||||
text: "RAM"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: SysMonitorService.sortBy === "memory" ? Font.Bold : Font.Medium
|
||||
font.weight: DankgopService.sortBy === "memory" ? Font.Bold : Font.Medium
|
||||
color: Theme.surfaceText
|
||||
opacity: SysMonitorService.sortBy === "memory" ? 1 : 0.7
|
||||
opacity: DankgopService.sortBy === "memory" ? 1 : 0.7
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
SysMonitorService.setSortBy("memory")
|
||||
DankgopService.setSortBy("memory")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +159,9 @@ Column {
|
||||
text: "PID"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: SysMonitorService.sortBy === "pid" ? Font.Bold : Font.Medium
|
||||
font.weight: DankgopService.sortBy === "pid" ? Font.Bold : Font.Medium
|
||||
color: Theme.surfaceText
|
||||
opacity: SysMonitorService.sortBy === "pid" ? 1 : 0.7
|
||||
opacity: DankgopService.sortBy === "pid" ? 1 : 0.7
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
@@ -173,7 +173,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
SysMonitorService.setSortBy("pid")
|
||||
DankgopService.setSortBy("pid")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.sortDescending ? "↓" : "↑"
|
||||
text: DankgopService.sortDescending ? "↓" : "↑"
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
anchors.centerIn: parent
|
||||
@@ -210,7 +210,7 @@ Column {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
SysMonitorService.toggleSortOrder()
|
||||
// ! TODO - we lost this with dankgop
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ Column {
|
||||
height: parent.height - columnHeaders.height
|
||||
clip: true
|
||||
spacing: 4
|
||||
model: SysMonitorService.processes
|
||||
model: DankgopService.processes
|
||||
|
||||
delegate: ProcessListItem {
|
||||
process: modelData
|
||||
|
||||
@@ -8,10 +8,10 @@ Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef();
|
||||
DankgopService.addRef(["cpu", "memory", "system"]);
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef();
|
||||
DankgopService.removeRef(["cpu", "memory", "system"]);
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -19,15 +19,15 @@ Row {
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (SysMonitorService.sortBy === "cpu")
|
||||
if (DankgopService.sortBy === "cpu")
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.16);
|
||||
else if (cpuCardMouseArea.containsMouse)
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12);
|
||||
else
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08);
|
||||
}
|
||||
border.color: SysMonitorService.sortBy === "cpu" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||
border.width: SysMonitorService.sortBy === "cpu" ? 2 : 1
|
||||
border.color: DankgopService.sortBy === "cpu" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||
border.width: DankgopService.sortBy === "cpu" ? 2 : 1
|
||||
|
||||
MouseArea {
|
||||
id: cpuCardMouseArea
|
||||
@@ -35,7 +35,7 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: SysMonitorService.setSortBy("cpu")
|
||||
onClicked: DankgopService.setSortBy("cpu")
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -48,15 +48,19 @@ Row {
|
||||
text: "CPU"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: SysMonitorService.sortBy === "cpu" ? Theme.primary : Theme.secondary
|
||||
opacity: SysMonitorService.sortBy === "cpu" ? 1 : 0.8
|
||||
color: DankgopService.sortBy === "cpu" ? Theme.primary : Theme.secondary
|
||||
opacity: DankgopService.sortBy === "cpu" ? 1 : 0.8
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalCpuUsage.toFixed(1) + "%"
|
||||
text: {
|
||||
if (DankgopService.cpuUsage === undefined || DankgopService.cpuUsage === null)
|
||||
return "--%"
|
||||
return DankgopService.cpuUsage.toFixed(1) + "%"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
@@ -73,19 +77,19 @@ Row {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.cpuTemperature === undefined || SysMonitorService.cpuTemperature === null || SysMonitorService.cpuTemperature < 0)
|
||||
if (DankgopService.cpuTemperature === undefined || DankgopService.cpuTemperature === null || DankgopService.cpuTemperature <= 0)
|
||||
return "--°";
|
||||
|
||||
return Math.round(SysMonitorService.cpuTemperature) + "°";
|
||||
return Math.round(DankgopService.cpuTemperature) + "°";
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Medium
|
||||
color: {
|
||||
if (SysMonitorService.cpuTemperature > 80)
|
||||
if (DankgopService.cpuTemperature > 80)
|
||||
return Theme.error;
|
||||
|
||||
if (SysMonitorService.cpuTemperature > 60)
|
||||
if (DankgopService.cpuTemperature > 60)
|
||||
return Theme.warning;
|
||||
|
||||
return Theme.surfaceText;
|
||||
@@ -96,7 +100,7 @@ Row {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.cpuCount + " cores"
|
||||
text: DankgopService.cpuCores + " cores"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Theme.surfaceText
|
||||
@@ -126,15 +130,15 @@ Row {
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (SysMonitorService.sortBy === "memory")
|
||||
if (DankgopService.sortBy === "memory")
|
||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.16);
|
||||
else if (memoryCardMouseArea.containsMouse)
|
||||
return Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.12);
|
||||
else
|
||||
return Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.08);
|
||||
}
|
||||
border.color: SysMonitorService.sortBy === "memory" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.2)
|
||||
border.width: SysMonitorService.sortBy === "memory" ? 2 : 1
|
||||
border.color: DankgopService.sortBy === "memory" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4) : Qt.rgba(Theme.secondary.r, Theme.secondary.g, Theme.secondary.b, 0.2)
|
||||
border.width: DankgopService.sortBy === "memory" ? 2 : 1
|
||||
|
||||
MouseArea {
|
||||
id: memoryCardMouseArea
|
||||
@@ -142,7 +146,7 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: SysMonitorService.setSortBy("memory")
|
||||
onClicked: DankgopService.setSortBy("memory")
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -155,15 +159,15 @@ Row {
|
||||
text: "Memory"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: SysMonitorService.sortBy === "memory" ? Theme.primary : Theme.secondary
|
||||
opacity: SysMonitorService.sortBy === "memory" ? 1 : 0.8
|
||||
color: DankgopService.sortBy === "memory" ? Theme.primary : Theme.secondary
|
||||
opacity: DankgopService.sortBy === "memory" ? 1 : 0.8
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.formatSystemMemory(SysMonitorService.usedMemoryKB)
|
||||
text: DankgopService.formatSystemMemory(DankgopService.usedMemoryKB)
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
@@ -176,27 +180,27 @@ Row {
|
||||
height: 20
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.3)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: SysMonitorService.totalSwapKB > 0
|
||||
visible: DankgopService.totalSwapKB > 0
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.totalSwapKB > 0 ? SysMonitorService.formatSystemMemory(SysMonitorService.usedSwapKB) : ""
|
||||
text: DankgopService.totalSwapKB > 0 ? DankgopService.formatSystemMemory(DankgopService.usedSwapKB) : ""
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Medium
|
||||
color: SysMonitorService.usedSwapKB > 0 ? Theme.warning : Theme.surfaceText
|
||||
color: DankgopService.usedSwapKB > 0 ? Theme.warning : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: SysMonitorService.totalSwapKB > 0
|
||||
visible: DankgopService.totalSwapKB > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.totalSwapKB > 0)
|
||||
return "of " + SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB) + " + swap";
|
||||
if (DankgopService.totalSwapKB > 0)
|
||||
return "of " + DankgopService.formatSystemMemory(DankgopService.totalMemoryKB) + " + swap";
|
||||
|
||||
return "of " + SysMonitorService.formatSystemMemory(SysMonitorService.totalMemoryKB);
|
||||
return "of " + DankgopService.formatSystemMemory(DankgopService.totalMemoryKB);
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
@@ -227,40 +231,40 @@ Row {
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.16);
|
||||
else
|
||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08);
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var vendor = gpu.vendor.toLowerCase();
|
||||
if (vendor.includes("nvidia")) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.2);
|
||||
else
|
||||
return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.12);
|
||||
} else if (vendor.includes("amd")) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.2);
|
||||
else
|
||||
return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12);
|
||||
} else if (vendor.includes("intel")) {
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.info.r, Theme.info.g, Theme.info.b, 0.2);
|
||||
else
|
||||
return Qt.rgba(Theme.info.r, Theme.info.g, Theme.info.b, 0.12);
|
||||
}
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1)
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1)
|
||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.16);
|
||||
else
|
||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08);
|
||||
}
|
||||
border.color: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.2);
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var vendor = gpu.vendor.toLowerCase();
|
||||
if (vendor.includes("nvidia"))
|
||||
return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.3);
|
||||
@@ -278,11 +282,11 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: SysMonitorService.availableGpus.length > 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
cursorShape: DankgopService.availableGpus.length > 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: (mouse) => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
if (SysMonitorService.availableGpus.length > 1) {
|
||||
var nextIndex = (SessionData.selectedGpuIndex + 1) % SysMonitorService.availableGpus.length;
|
||||
if (DankgopService.availableGpus.length > 1) {
|
||||
var nextIndex = (SessionData.selectedGpuIndex + 1) % DankgopService.availableGpus.length;
|
||||
SessionData.setSelectedGpuIndex(nextIndex);
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
@@ -307,12 +311,14 @@ Row {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return "No GPU";
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
// Check if temperature monitoring is enabled for this GPU
|
||||
var tempEnabled = SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1;
|
||||
var temp = gpu.temperature;
|
||||
var hasTemp = temp !== undefined && temp !== null && temp !== 0;
|
||||
var hasTemp = tempEnabled && temp !== undefined && temp !== null && temp !== 0;
|
||||
if (hasTemp)
|
||||
return Math.round(temp) + "°";
|
||||
else
|
||||
@@ -322,15 +328,16 @@ Row {
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Bold
|
||||
color: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return Theme.surfaceText;
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var tempEnabled = SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1;
|
||||
var temp = gpu.temperature || 0;
|
||||
if (temp > 80)
|
||||
if (tempEnabled && temp > 80)
|
||||
return Theme.error;
|
||||
|
||||
if (temp > 60)
|
||||
if (tempEnabled && temp > 60)
|
||||
return Theme.warning;
|
||||
|
||||
return Theme.surfaceText;
|
||||
@@ -339,12 +346,13 @@ Row {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0)
|
||||
return "No GPUs detected";
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)];
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)];
|
||||
var tempEnabled = SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1;
|
||||
var temp = gpu.temperature;
|
||||
var hasTemp = temp !== undefined && temp !== null && temp !== 0;
|
||||
var hasTemp = tempEnabled && temp !== undefined && temp !== null && temp !== 0;
|
||||
if (hasTemp)
|
||||
return gpu.vendor + " " + gpu.displayName;
|
||||
else
|
||||
@@ -365,41 +373,40 @@ Row {
|
||||
id: gpuContextMenu
|
||||
|
||||
MenuItem {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
return "Enable GPU Temperature"
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var isNvidia = gpu.vendor.toLowerCase().includes("nvidia")
|
||||
return isNvidia ? "Enable GPU Temperature" : "Enable GPU Temperature"
|
||||
}
|
||||
text: "Enable GPU Temperature"
|
||||
checkable: true
|
||||
checked: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var isNvidia = gpu.vendor.toLowerCase().includes("nvidia")
|
||||
return isNvidia ? SysMonitorService.nvidiaGpuTempEnabled : SysMonitorService.nonNvidiaGpuTempEnabled
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)]
|
||||
if (!gpu.pciId) return false
|
||||
|
||||
return SessionData.enabledGpuPciIds ? SessionData.enabledGpuPciIds.indexOf(gpu.pciId) !== -1 : false
|
||||
}
|
||||
onTriggered: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var isNvidia = gpu.vendor.toLowerCase().includes("nvidia")
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)]
|
||||
if (!gpu.pciId) return
|
||||
|
||||
if (isNvidia) {
|
||||
SessionData.setNvidiaGpuTempEnabled(checked)
|
||||
} else {
|
||||
SessionData.setNonNvidiaGpuTempEnabled(checked)
|
||||
var enabledIds = SessionData.enabledGpuPciIds ? SessionData.enabledGpuPciIds.slice() : []
|
||||
var index = enabledIds.indexOf(gpu.pciId)
|
||||
|
||||
if (checked && index === -1) {
|
||||
enabledIds.push(gpu.pciId)
|
||||
DankgopService.addGpuPciId(gpu.pciId)
|
||||
} else if (!checked && index !== -1) {
|
||||
enabledIds.splice(index, 1)
|
||||
DankgopService.removeGpuPciId(gpu.pciId)
|
||||
}
|
||||
|
||||
SessionData.setEnabledGpuPciIds(enabledIds)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
|
||||
@@ -10,10 +10,10 @@ ScrollView {
|
||||
ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["system", "hardware", "diskmounts"])
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["system", "hardware", "diskmounts"])
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -52,7 +52,7 @@ ScrollView {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.hostname
|
||||
text: DankgopService.hostname
|
||||
font.pixelSize: Theme.fontSizeXLarge
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Light
|
||||
@@ -61,8 +61,8 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.distribution + " • " + SysMonitorService.architecture
|
||||
+ " • " + SysMonitorService.kernelVersion
|
||||
text: DankgopService.distribution + " • " + DankgopService.architecture
|
||||
+ " • " + DankgopService.kernelVersion
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
@@ -71,7 +71,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "Up " + UserInfoService.uptime + " • Boot: " + SysMonitorService.bootTime
|
||||
text: "Up " + UserInfoService.uptime + " • Boot: " + DankgopService.bootTime
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
@@ -80,9 +80,9 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "Load: " + SysMonitorService.loadAverage + " • "
|
||||
+ SysMonitorService.processCount + " processes, "
|
||||
+ SysMonitorService.threadCount + " threads"
|
||||
text: "Load: " + DankgopService.loadAverage + " • "
|
||||
+ DankgopService.processCount + " processes, "
|
||||
+ DankgopService.threadCount + " threads"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
@@ -144,7 +144,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.cpuModel
|
||||
text: DankgopService.cpuModel
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
font.weight: Font.Medium
|
||||
@@ -157,7 +157,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.motherboard
|
||||
text: DankgopService.motherboard
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
@@ -170,7 +170,7 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "BIOS " + SysMonitorService.biosVersion
|
||||
text: "BIOS " + DankgopService.biosVersion
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
@@ -181,8 +181,8 @@ ScrollView {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SysMonitorService.formatSystemMemory(
|
||||
SysMonitorService.totalMemoryKB) + " RAM"
|
||||
text: DankgopService.formatSystemMemory(
|
||||
DankgopService.totalMemoryKB) + " RAM"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
@@ -206,11 +206,11 @@ ScrollView {
|
||||
Theme.surfaceContainerHigh.g,
|
||||
Theme.surfaceContainerHigh.b, 0.6)
|
||||
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
return gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1 ? hoverColor : baseColor
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
return gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1 ? hoverColor : baseColor
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)]
|
||||
var vendor = gpu.fullName.split(' ')[0].toLowerCase()
|
||||
var tintColor
|
||||
|
||||
@@ -221,10 +221,10 @@ ScrollView {
|
||||
} else if (vendor.includes("intel")) {
|
||||
tintColor = Theme.info
|
||||
} else {
|
||||
return gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1 ? hoverColor : baseColor
|
||||
return gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1 ? hoverColor : baseColor
|
||||
}
|
||||
|
||||
if (gpuCardMouseArea.containsMouse && SysMonitorService.availableGpus.length > 1) {
|
||||
if (gpuCardMouseArea.containsMouse && DankgopService.availableGpus.length > 1) {
|
||||
return Qt.rgba((hoverColor.r + tintColor.r * 0.1) / 1.1,
|
||||
(hoverColor.g + tintColor.g * 0.1) / 1.1,
|
||||
(hoverColor.b + tintColor.b * 0.1) / 1.1, 0.6)
|
||||
@@ -236,11 +236,11 @@ ScrollView {
|
||||
}
|
||||
border.width: 1
|
||||
border.color: {
|
||||
if (!SysMonitorService.availableGpus || SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus || DankgopService.availableGpus.length === 0) {
|
||||
return Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
|
||||
}
|
||||
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(SessionData.selectedGpuIndex, SysMonitorService.availableGpus.length - 1)]
|
||||
var gpu = DankgopService.availableGpus[Math.min(SessionData.selectedGpuIndex, DankgopService.availableGpus.length - 1)]
|
||||
var vendor = gpu.fullName.split(' ')[0].toLowerCase()
|
||||
|
||||
if (vendor.includes("nvidia")) {
|
||||
@@ -258,12 +258,12 @@ ScrollView {
|
||||
id: gpuCardMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: SysMonitorService.availableGpus.length
|
||||
cursorShape: DankgopService.availableGpus.length
|
||||
> 1 ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: {
|
||||
if (SysMonitorService.availableGpus.length > 1) {
|
||||
if (DankgopService.availableGpus.length > 1) {
|
||||
var nextIndex = (SessionData.selectedGpuIndex + 1)
|
||||
% SysMonitorService.availableGpus.length
|
||||
% DankgopService.availableGpus.length
|
||||
SessionData.setSelectedGpuIndex(nextIndex)
|
||||
}
|
||||
}
|
||||
@@ -301,13 +301,13 @@ ScrollView {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus
|
||||
|| SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus
|
||||
|| DankgopService.availableGpus.length === 0) {
|
||||
return "No GPUs detected"
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(
|
||||
var gpu = DankgopService.availableGpus[Math.min(
|
||||
SessionData.selectedGpuIndex,
|
||||
SysMonitorService.availableGpus.length
|
||||
DankgopService.availableGpus.length
|
||||
- 1)]
|
||||
return gpu.fullName
|
||||
}
|
||||
@@ -323,13 +323,13 @@ ScrollView {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus
|
||||
|| SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus
|
||||
|| DankgopService.availableGpus.length === 0) {
|
||||
return "Device: N/A"
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(
|
||||
var gpu = DankgopService.availableGpus[Math.min(
|
||||
SessionData.selectedGpuIndex,
|
||||
SysMonitorService.availableGpus.length
|
||||
DankgopService.availableGpus.length
|
||||
- 1)]
|
||||
return "Device: " + gpu.pciId
|
||||
}
|
||||
@@ -345,13 +345,13 @@ ScrollView {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus
|
||||
|| SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus
|
||||
|| DankgopService.availableGpus.length === 0) {
|
||||
return "Driver: N/A"
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(
|
||||
var gpu = DankgopService.availableGpus[Math.min(
|
||||
SessionData.selectedGpuIndex,
|
||||
SysMonitorService.availableGpus.length
|
||||
DankgopService.availableGpus.length
|
||||
- 1)]
|
||||
return "Driver: " + gpu.driver
|
||||
}
|
||||
@@ -366,13 +366,13 @@ ScrollView {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!SysMonitorService.availableGpus
|
||||
|| SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus
|
||||
|| DankgopService.availableGpus.length === 0) {
|
||||
return "Temp: --°"
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(
|
||||
var gpu = DankgopService.availableGpus[Math.min(
|
||||
SessionData.selectedGpuIndex,
|
||||
SysMonitorService.availableGpus.length
|
||||
DankgopService.availableGpus.length
|
||||
- 1)]
|
||||
var temp = gpu.temperature
|
||||
return "Temp: " + ((temp === undefined || temp === null
|
||||
@@ -382,14 +382,14 @@ ScrollView {
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.family: SettingsData.monoFontFamily
|
||||
color: {
|
||||
if (!SysMonitorService.availableGpus
|
||||
|| SysMonitorService.availableGpus.length === 0) {
|
||||
if (!DankgopService.availableGpus
|
||||
|| DankgopService.availableGpus.length === 0) {
|
||||
return Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.7)
|
||||
}
|
||||
var gpu = SysMonitorService.availableGpus[Math.min(
|
||||
var gpu = DankgopService.availableGpus[Math.min(
|
||||
SessionData.selectedGpuIndex,
|
||||
SysMonitorService.availableGpus.length
|
||||
DankgopService.availableGpus.length
|
||||
- 1)]
|
||||
var temp = gpu.temperature || 0
|
||||
if (temp > 80)
|
||||
@@ -532,7 +532,7 @@ ScrollView {
|
||||
Repeater {
|
||||
id: diskMountRepeater
|
||||
|
||||
model: SysMonitorService.diskMounts
|
||||
model: DankgopService.diskMounts
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Item {
|
||||
@@ -53,26 +54,29 @@ Item {
|
||||
"text": "CPU Usage",
|
||||
"description": "CPU usage indicator",
|
||||
"icon": "memory",
|
||||
"enabled": true
|
||||
"enabled": DankgopService.dankgopAvailable,
|
||||
"warning": !DankgopService.dankgopAvailable ? "Requires 'dankgop' tool" : undefined
|
||||
}, {
|
||||
"id": "memUsage",
|
||||
"text": "Memory Usage",
|
||||
"description": "Memory usage indicator",
|
||||
"icon": "storage",
|
||||
"enabled": true
|
||||
"enabled": DankgopService.dankgopAvailable,
|
||||
"warning": !DankgopService.dankgopAvailable ? "Requires 'dankgop' tool" : undefined
|
||||
}, {
|
||||
"id": "cpuTemp",
|
||||
"text": "CPU Temperature",
|
||||
"description": "CPU temperature display",
|
||||
"icon": "device_thermostat",
|
||||
"enabled": true
|
||||
"enabled": DankgopService.dankgopAvailable,
|
||||
"warning": !DankgopService.dankgopAvailable ? "Requires 'dankgop' tool" : undefined
|
||||
}, {
|
||||
"id": "gpuTemp",
|
||||
"text": "GPU Temperature",
|
||||
"description": "GPU temperature display",
|
||||
"icon": "auto_awesome_mosaic",
|
||||
"warning": "This widget prevents GPU power off states, which can significantly impact battery life on laptops. It is not recommended to use this on laptops with hybrid graphics.",
|
||||
"enabled": true
|
||||
"warning": !DankgopService.dankgopAvailable ? "Requires 'dankgop' tool" : "This widget prevents GPU power off states, which can significantly impact battery life on laptops. It is not recommended to use this on laptops with hybrid graphics.",
|
||||
"enabled": DankgopService.dankgopAvailable
|
||||
}, {
|
||||
"id": "systemTray",
|
||||
"text": "System Tray",
|
||||
@@ -145,12 +149,6 @@ Item {
|
||||
}, {
|
||||
"id": "clipboard",
|
||||
"enabled": true
|
||||
}, {
|
||||
"id": "cpuUsage",
|
||||
"enabled": true
|
||||
}, {
|
||||
"id": "memUsage",
|
||||
"enabled": true
|
||||
}, {
|
||||
"id": "notificationButton",
|
||||
"enabled": true
|
||||
@@ -169,8 +167,10 @@ Item {
|
||||
}
|
||||
if (widgetId === "spacer")
|
||||
widgetObj.size = 20
|
||||
if (widgetId === "gpuTemp")
|
||||
if (widgetId === "gpuTemp") {
|
||||
widgetObj.selectedGpuIndex = 0
|
||||
widgetObj.pciId = ""
|
||||
}
|
||||
|
||||
var widgets = []
|
||||
if (targetSection === "left") {
|
||||
@@ -223,14 +223,22 @@ Item {
|
||||
var widget = widgets[i]
|
||||
var widgetId = typeof widget === "string" ? widget : widget.id
|
||||
if (widgetId === itemId) {
|
||||
widgets[i] = typeof widget === "string" ? {
|
||||
"id": widget,
|
||||
"enabled": enabled
|
||||
} : {
|
||||
"id": widget.id,
|
||||
"enabled": enabled,
|
||||
"size": widget.size,
|
||||
"selectedGpuIndex": widget.selectedGpuIndex
|
||||
if (typeof widget === "string") {
|
||||
widgets[i] = {
|
||||
"id": widget,
|
||||
"enabled": enabled
|
||||
}
|
||||
} else {
|
||||
var newWidget = {
|
||||
"id": widget.id,
|
||||
"enabled": enabled
|
||||
}
|
||||
if (widget.size !== undefined) newWidget.size = widget.size
|
||||
if (widget.selectedGpuIndex !== undefined) newWidget.selectedGpuIndex = widget.selectedGpuIndex
|
||||
else if (widget.id === "gpuTemp") newWidget.selectedGpuIndex = 0
|
||||
if (widget.pciId !== undefined) newWidget.pciId = widget.pciId
|
||||
else if (widget.id === "gpuTemp") newWidget.pciId = ""
|
||||
widgets[i] = newWidget
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -264,15 +272,21 @@ Item {
|
||||
var widget = widgets[i]
|
||||
var widgetId = typeof widget === "string" ? widget : widget.id
|
||||
if (widgetId === itemId && widgetId === "spacer") {
|
||||
widgets[i] = typeof widget === "string" ? {
|
||||
"id": widget,
|
||||
"enabled": true,
|
||||
"size": newSize
|
||||
} : {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled,
|
||||
"size": newSize,
|
||||
"selectedGpuIndex": widget.selectedGpuIndex
|
||||
if (typeof widget === "string") {
|
||||
widgets[i] = {
|
||||
"id": widget,
|
||||
"enabled": true,
|
||||
"size": newSize
|
||||
}
|
||||
} else {
|
||||
var newWidget = {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled,
|
||||
"size": newSize
|
||||
}
|
||||
if (widget.selectedGpuIndex !== undefined) newWidget.selectedGpuIndex = widget.selectedGpuIndex
|
||||
if (widget.pciId !== undefined) newWidget.pciId = widget.pciId
|
||||
widgets[i] = newWidget
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -296,15 +310,22 @@ Item {
|
||||
|
||||
if (widgetIndex >= 0 && widgetIndex < widgets.length) {
|
||||
var widget = widgets[widgetIndex]
|
||||
widgets[widgetIndex] = typeof widget === "string" ? {
|
||||
"id": widget,
|
||||
"enabled": true,
|
||||
"selectedGpuIndex": selectedGpuIndex
|
||||
} : {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled,
|
||||
"size": widget.size,
|
||||
"selectedGpuIndex": selectedGpuIndex
|
||||
if (typeof widget === "string") {
|
||||
widgets[widgetIndex] = {
|
||||
"id": widget,
|
||||
"enabled": true,
|
||||
"selectedGpuIndex": selectedGpuIndex,
|
||||
"pciId": DankgopService.availableGpus && DankgopService.availableGpus.length > selectedGpuIndex ? DankgopService.availableGpus[selectedGpuIndex].pciId : ""
|
||||
}
|
||||
} else {
|
||||
var newWidget = {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled,
|
||||
"selectedGpuIndex": selectedGpuIndex,
|
||||
"pciId": DankgopService.availableGpus && DankgopService.availableGpus.length > selectedGpuIndex ? DankgopService.availableGpus[selectedGpuIndex].pciId : ""
|
||||
}
|
||||
if (widget.size !== undefined) newWidget.size = widget.size
|
||||
widgets[widgetIndex] = newWidget
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +352,8 @@ Item {
|
||||
var widgetSize = typeof widget === "string" ? undefined : widget.size
|
||||
var widgetSelectedGpuIndex = typeof widget
|
||||
=== "string" ? undefined : widget.selectedGpuIndex
|
||||
var widgetPciId = typeof widget
|
||||
=== "string" ? undefined : widget.pciId
|
||||
var widgetDef = baseWidgetDefinitions.find(w => {
|
||||
return w.id === widgetId
|
||||
})
|
||||
@@ -341,6 +364,8 @@ Item {
|
||||
item.size = widgetSize
|
||||
if (widgetSelectedGpuIndex !== undefined)
|
||||
item.selectedGpuIndex = widgetSelectedGpuIndex
|
||||
if (widgetPciId !== undefined)
|
||||
item.pciId = widgetPciId
|
||||
|
||||
widgets.push(item)
|
||||
}
|
||||
@@ -359,8 +384,9 @@ Item {
|
||||
|
||||
if (!SettingsData.topBarRightWidgets
|
||||
|| SettingsData.topBarRightWidgets.length === 0)
|
||||
SettingsData.setTopBarRightWidgets(
|
||||
defaultRightWidgets)["left", "center", "right"].forEach(sectionId => {
|
||||
SettingsData.setTopBarRightWidgets(defaultRightWidgets)
|
||||
|
||||
["left", "center", "right"].forEach(sectionId => {
|
||||
var widgets = []
|
||||
if (sectionId === "left")
|
||||
widgets = SettingsData.topBarLeftWidgets.slice()
|
||||
|
||||
@@ -148,29 +148,23 @@ Column {
|
||||
currentValue: {
|
||||
var selectedIndex = modelData.selectedGpuIndex
|
||||
!== undefined ? modelData.selectedGpuIndex : 0
|
||||
if (SysMonitorService.availableGpus
|
||||
&& SysMonitorService.availableGpus.length > selectedIndex
|
||||
if (DankgopService.availableGpus
|
||||
&& DankgopService.availableGpus.length > selectedIndex
|
||||
&& selectedIndex >= 0) {
|
||||
var gpu = SysMonitorService.availableGpus[selectedIndex]
|
||||
return gpu.driver.toUpperCase() + " (" + Math.round(
|
||||
gpu.temperature || 0) + "°C)"
|
||||
var gpu = DankgopService.availableGpus[selectedIndex]
|
||||
return gpu.driver.toUpperCase()
|
||||
}
|
||||
return SysMonitorService.availableGpus
|
||||
&& SysMonitorService.availableGpus.length
|
||||
> 0 ? SysMonitorService.availableGpus[0].driver.toUpperCase(
|
||||
) + " (" + Math.round(
|
||||
SysMonitorService.availableGpus[0].temperature
|
||||
|| 0) + "°C)" : ""
|
||||
return DankgopService.availableGpus
|
||||
&& DankgopService.availableGpus.length
|
||||
> 0 ? DankgopService.availableGpus[0].driver.toUpperCase() : ""
|
||||
}
|
||||
options: {
|
||||
var gpuOptions = []
|
||||
if (SysMonitorService.availableGpus
|
||||
&& SysMonitorService.availableGpus.length > 0) {
|
||||
for (var i = 0; i < SysMonitorService.availableGpus.length; i++) {
|
||||
var gpu = SysMonitorService.availableGpus[i]
|
||||
gpuOptions.push(gpu.driver.toUpperCase(
|
||||
) + " (" + Math.round(gpu.temperature
|
||||
|| 0) + "°C)")
|
||||
if (DankgopService.availableGpus
|
||||
&& DankgopService.availableGpus.length > 0) {
|
||||
for (var i = 0; i < DankgopService.availableGpus.length; i++) {
|
||||
var gpu = DankgopService.availableGpus[i]
|
||||
gpuOptions.push(gpu.driver.toUpperCase())
|
||||
}
|
||||
}
|
||||
return gpuOptions
|
||||
@@ -188,7 +182,7 @@ Column {
|
||||
Item {
|
||||
width: 32
|
||||
height: 32
|
||||
visible: modelData.id === "gpuTemp" && modelData.warning
|
||||
visible: (modelData.warning !== undefined && modelData.warning !== "") && (modelData.id === "cpuUsage" || modelData.id === "memUsage" || modelData.id === "cpuTemp" || modelData.id === "gpuTemp")
|
||||
|
||||
DankIcon {
|
||||
name: "warning"
|
||||
@@ -207,13 +201,16 @@ Column {
|
||||
|
||||
Rectangle {
|
||||
id: warningTooltip
|
||||
width: warningTooltipText.contentWidth + Theme.spacingM * 2
|
||||
height: warningTooltipText.contentHeight + Theme.spacingS * 2
|
||||
|
||||
property string warningText: (modelData.warning !== undefined && modelData.warning !== "") ? modelData.warning : ""
|
||||
|
||||
width: Math.min(250, warningTooltipText.implicitWidth) + Theme.spacingM * 2
|
||||
height: warningTooltipText.implicitHeight + Theme.spacingS * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.surfaceContainer
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
visible: warningArea.containsMouse
|
||||
visible: warningArea.containsMouse && warningText !== ""
|
||||
opacity: visible ? 1 : 0
|
||||
x: -width - Theme.spacingS
|
||||
y: (parent.height - height) / 2
|
||||
@@ -222,10 +219,11 @@ Column {
|
||||
StyledText {
|
||||
id: warningTooltipText
|
||||
anchors.centerIn: parent
|
||||
text: modelData.warning || "Warning"
|
||||
anchors.margins: Theme.spacingS
|
||||
text: warningTooltip.warningText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
width: 300
|
||||
width: Math.min(250, implicitWidth)
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ Rectangle {
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["cpu"])
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["cpu"])
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -45,7 +45,7 @@ Rectangle {
|
||||
Theme.barHeight + Theme.spacingXS,
|
||||
width, section, currentScreen)
|
||||
}
|
||||
SysMonitorService.setSortBy("cpu")
|
||||
DankgopService.setSortBy("cpu")
|
||||
if (root.toggleProcessList)
|
||||
root.toggleProcessList()
|
||||
}
|
||||
@@ -59,10 +59,10 @@ Rectangle {
|
||||
name: "memory"
|
||||
size: Theme.iconSize - 8
|
||||
color: {
|
||||
if (SysMonitorService.cpuUsage > 80)
|
||||
if (DankgopService.cpuUsage > 80)
|
||||
return Theme.tempDanger
|
||||
|
||||
if (SysMonitorService.cpuUsage > 60)
|
||||
if (DankgopService.cpuUsage > 60)
|
||||
return Theme.tempWarning
|
||||
|
||||
return Theme.surfaceText
|
||||
@@ -72,12 +72,12 @@ Rectangle {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.cpuUsage === undefined
|
||||
|| SysMonitorService.cpuUsage === null
|
||||
|| SysMonitorService.cpuUsage === 0) {
|
||||
if (DankgopService.cpuUsage === undefined
|
||||
|| DankgopService.cpuUsage === null
|
||||
|| DankgopService.cpuUsage === 0) {
|
||||
return "--%"
|
||||
}
|
||||
return SysMonitorService.cpuUsage.toFixed(0) + "%"
|
||||
return DankgopService.cpuUsage.toFixed(0) + "%"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
|
||||
@@ -23,10 +23,10 @@ Rectangle {
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["cpu"])
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["cpu"])
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -45,7 +45,7 @@ Rectangle {
|
||||
Theme.barHeight + Theme.spacingXS,
|
||||
width, section, currentScreen)
|
||||
}
|
||||
SysMonitorService.setSortBy("cpu")
|
||||
DankgopService.setSortBy("cpu")
|
||||
if (root.toggleProcessList)
|
||||
root.toggleProcessList()
|
||||
}
|
||||
@@ -59,10 +59,10 @@ Rectangle {
|
||||
name: "memory"
|
||||
size: Theme.iconSize - 8
|
||||
color: {
|
||||
if (SysMonitorService.cpuTemperature > 85)
|
||||
if (DankgopService.cpuTemperature > 85)
|
||||
return Theme.tempDanger
|
||||
|
||||
if (SysMonitorService.cpuTemperature > 69)
|
||||
if (DankgopService.cpuTemperature > 69)
|
||||
return Theme.tempWarning
|
||||
|
||||
return Theme.surfaceText
|
||||
@@ -72,12 +72,12 @@ Rectangle {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.cpuTemperature === undefined
|
||||
|| SysMonitorService.cpuTemperature === null
|
||||
|| SysMonitorService.cpuTemperature < 0) {
|
||||
if (DankgopService.cpuTemperature === undefined
|
||||
|| DankgopService.cpuTemperature === null
|
||||
|| DankgopService.cpuTemperature < 0) {
|
||||
return "--°"
|
||||
}
|
||||
return Math.round(SysMonitorService.cpuTemperature) + "°"
|
||||
return Math.round(DankgopService.cpuTemperature) + "°"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
|
||||
@@ -37,19 +37,33 @@ Rectangle {
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["gpu"])
|
||||
console.log("GpuTemperature widget - pciId:", widgetData ? widgetData.pciId : "no widgetData", "selectedGpuIndex:", widgetData ? widgetData.selectedGpuIndex : "no widgetData")
|
||||
// Add this widget's PCI ID to the service
|
||||
if (widgetData && widgetData.pciId) {
|
||||
console.log("Adding GPU PCI ID to service:", widgetData.pciId)
|
||||
DankgopService.addGpuPciId(widgetData.pciId)
|
||||
} else {
|
||||
console.log("No PCI ID in widget data, starting auto-detection")
|
||||
// No PCI ID saved, auto-detect and save the first GPU
|
||||
autoSaveTimer.running = true
|
||||
}
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["gpu"])
|
||||
// Remove this widget's PCI ID from the service
|
||||
if (widgetData && widgetData.pciId) {
|
||||
DankgopService.removeGpuPciId(widgetData.pciId)
|
||||
}
|
||||
}
|
||||
|
||||
property real displayTemp: {
|
||||
if (!SysMonitorService.availableGpus
|
||||
|| SysMonitorService.availableGpus.length === 0)
|
||||
if (!DankgopService.availableGpus
|
||||
|| DankgopService.availableGpus.length === 0)
|
||||
return 0
|
||||
if (selectedGpuIndex >= 0
|
||||
&& selectedGpuIndex < SysMonitorService.availableGpus.length) {
|
||||
return SysMonitorService.availableGpus[selectedGpuIndex].temperature || 0
|
||||
&& selectedGpuIndex < DankgopService.availableGpus.length) {
|
||||
return DankgopService.availableGpus[selectedGpuIndex].temperature || 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -70,7 +84,7 @@ Rectangle {
|
||||
Theme.barHeight + Theme.spacingXS,
|
||||
width, section, currentScreen)
|
||||
}
|
||||
SysMonitorService.setSortBy("cpu")
|
||||
DankgopService.setSortBy("cpu")
|
||||
if (root.toggleProcessList)
|
||||
root.toggleProcessList()
|
||||
}
|
||||
@@ -116,4 +130,57 @@ Rectangle {
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: autoSaveTimer
|
||||
interval: 100
|
||||
running: false
|
||||
onTriggered: {
|
||||
if (DankgopService.availableGpus && DankgopService.availableGpus.length > 0) {
|
||||
const firstGpu = DankgopService.availableGpus[0]
|
||||
if (firstGpu && firstGpu.pciId) {
|
||||
// Save the first GPU's PCI ID to this widget's settings
|
||||
updateWidgetPciId(firstGpu.pciId)
|
||||
DankgopService.addGpuPciId(firstGpu.pciId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateWidgetPciId(pciId) {
|
||||
// Find and update this widget's pciId in the settings
|
||||
var sections = ["left", "center", "right"]
|
||||
for (var s = 0; s < sections.length; s++) {
|
||||
var sectionId = sections[s]
|
||||
var widgets = []
|
||||
if (sectionId === "left")
|
||||
widgets = SettingsData.topBarLeftWidgets.slice()
|
||||
else if (sectionId === "center")
|
||||
widgets = SettingsData.topBarCenterWidgets.slice()
|
||||
else if (sectionId === "right")
|
||||
widgets = SettingsData.topBarRightWidgets.slice()
|
||||
|
||||
for (var i = 0; i < widgets.length; i++) {
|
||||
var widget = widgets[i]
|
||||
if (typeof widget === "object" && widget.id === "gpuTemp"
|
||||
&& (!widget.pciId || widget.pciId === "")) {
|
||||
widgets[i] = {
|
||||
"id": widget.id,
|
||||
"enabled": widget.enabled !== undefined ? widget.enabled : true,
|
||||
"selectedGpuIndex": 0,
|
||||
"pciId": pciId
|
||||
}
|
||||
|
||||
if (sectionId === "left")
|
||||
SettingsData.setTopBarLeftWidgets(widgets)
|
||||
else if (sectionId === "center")
|
||||
SettingsData.setTopBarCenterWidgets(widgets)
|
||||
else if (sectionId === "right")
|
||||
SettingsData.setTopBarRightWidgets(widgets)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ Rectangle {
|
||||
baseColor.a * Theme.widgetTransparency)
|
||||
}
|
||||
Component.onCompleted: {
|
||||
SysMonitorService.addRef()
|
||||
DankgopService.addRef(["memory"])
|
||||
}
|
||||
Component.onDestruction: {
|
||||
SysMonitorService.removeRef()
|
||||
DankgopService.removeRef(["memory"])
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -45,7 +45,7 @@ Rectangle {
|
||||
Theme.barHeight + Theme.spacingXS,
|
||||
width, section, currentScreen)
|
||||
}
|
||||
SysMonitorService.setSortBy("memory")
|
||||
DankgopService.setSortBy("memory")
|
||||
if (root.toggleProcessList)
|
||||
root.toggleProcessList()
|
||||
}
|
||||
@@ -59,10 +59,10 @@ Rectangle {
|
||||
name: "developer_board"
|
||||
size: Theme.iconSize - 8
|
||||
color: {
|
||||
if (SysMonitorService.memoryUsage > 90)
|
||||
if (DankgopService.memoryUsage > 90)
|
||||
return Theme.tempDanger
|
||||
|
||||
if (SysMonitorService.memoryUsage > 75)
|
||||
if (DankgopService.memoryUsage > 75)
|
||||
return Theme.tempWarning
|
||||
|
||||
return Theme.surfaceText
|
||||
@@ -72,12 +72,12 @@ Rectangle {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (SysMonitorService.memoryUsage === undefined
|
||||
|| SysMonitorService.memoryUsage === null
|
||||
|| SysMonitorService.memoryUsage === 0) {
|
||||
if (DankgopService.memoryUsage === undefined
|
||||
|| DankgopService.memoryUsage === null
|
||||
|| DankgopService.memoryUsage === 0) {
|
||||
return "--%"
|
||||
}
|
||||
return SysMonitorService.memoryUsage.toFixed(0) + "%"
|
||||
return DankgopService.memoryUsage.toFixed(0) + "%"
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
|
||||
@@ -58,9 +58,9 @@ PanelWindow {
|
||||
return widgetId === "gpuTemp" && widgetEnabled
|
||||
})
|
||||
|
||||
SysMonitorService.gpuTempEnabled = hasGpuTempWidget || SessionData.nvidiaGpuTempEnabled || SessionData.nonNvidiaGpuTempEnabled
|
||||
SysMonitorService.nvidiaGpuTempEnabled = hasGpuTempWidget || SessionData.nvidiaGpuTempEnabled
|
||||
SysMonitorService.nonNvidiaGpuTempEnabled = hasGpuTempWidget || SessionData.nonNvidiaGpuTempEnabled
|
||||
DankgopService.gpuTempEnabled = hasGpuTempWidget || SessionData.nvidiaGpuTempEnabled || SessionData.nonNvidiaGpuTempEnabled
|
||||
DankgopService.nvidiaGpuTempEnabled = hasGpuTempWidget || SessionData.nvidiaGpuTempEnabled
|
||||
DankgopService.nonNvidiaGpuTempEnabled = hasGpuTempWidget || SessionData.nonNvidiaGpuTempEnabled
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -238,13 +238,13 @@ PanelWindow {
|
||||
case "clipboard":
|
||||
return true
|
||||
case "cpuUsage":
|
||||
return true
|
||||
return DankgopService.dankgopAvailable
|
||||
case "memUsage":
|
||||
return true
|
||||
return DankgopService.dankgopAvailable
|
||||
case "cpuTemp":
|
||||
return true
|
||||
return DankgopService.dankgopAvailable
|
||||
case "gpuTemp":
|
||||
return true
|
||||
return DankgopService.dankgopAvailable
|
||||
case "notificationButton":
|
||||
return true
|
||||
case "battery":
|
||||
|
||||
@@ -156,10 +156,16 @@ rm /tmp/FiraCode.zip && fc-cache -f
|
||||
|
||||
**Enhanced Functionality:**
|
||||
|
||||
```bash
|
||||
# Install dankgop on any distro (requires go 1.23+):
|
||||
git clone https://github.com/AvengeMedia/dankgop.git && cd dankgop
|
||||
make && sudo make install
|
||||
```
|
||||
|
||||
```bash
|
||||
# Arch Linux
|
||||
pacman -S cava wl-clipboard cliphist ddcutil brightnessctl
|
||||
paru -S matugen
|
||||
paru -S matugen dankgop-git
|
||||
|
||||
# Fedora
|
||||
sudo dnf install cava wl-clipboard ddcutil brightnessctl
|
||||
@@ -169,6 +175,7 @@ sudo dnf copr enable heus-sueh/packages && sudo dnf install matugen
|
||||
|
||||
**What you get:**
|
||||
|
||||
- `dankgop-git`: Ability to have system resource widgets, process list modal, and temperature monitoring.
|
||||
- `matugen`: Wallpaper-based dynamic theming
|
||||
- `ddcutil`: External monitor brightness control
|
||||
- `brightnessctl`: Laptop display brightness
|
||||
|
||||
562
Services/DankgopService.qml
Normal file
562
Services/DankgopService.qml
Normal file
@@ -0,0 +1,562 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property int refCount: 0
|
||||
property int updateInterval: refCount > 0 ? 3000 : 30000
|
||||
property bool isUpdating: false
|
||||
property bool dankgopAvailable: false
|
||||
|
||||
property var moduleRefCounts: ({})
|
||||
property var enabledModules: []
|
||||
property var gpuPciIds: []
|
||||
property var gpuPciIdRefCounts: ({})
|
||||
property int processLimit: 20
|
||||
property string processSort: "cpu"
|
||||
property bool noCpu: false
|
||||
|
||||
property real cpuUsage: 0
|
||||
property real cpuFrequency: 0
|
||||
property real cpuTemperature: 0
|
||||
property int cpuCores: 1
|
||||
property string cpuModel: ""
|
||||
property var perCoreCpuUsage: []
|
||||
|
||||
property real memoryUsage: 0
|
||||
property real totalMemoryMB: 0
|
||||
property real usedMemoryMB: 0
|
||||
property real freeMemoryMB: 0
|
||||
property real availableMemoryMB: 0
|
||||
property int totalMemoryKB: 0
|
||||
property int usedMemoryKB: 0
|
||||
property int totalSwapKB: 0
|
||||
property int usedSwapKB: 0
|
||||
|
||||
property real networkRxRate: 0
|
||||
property real networkTxRate: 0
|
||||
property var lastNetworkStats: null
|
||||
property var networkInterfaces: []
|
||||
|
||||
property real diskReadRate: 0
|
||||
property real diskWriteRate: 0
|
||||
property var lastDiskStats: null
|
||||
property var diskMounts: []
|
||||
property var diskDevices: []
|
||||
|
||||
property var processes: []
|
||||
property var availableGpus: []
|
||||
|
||||
property string kernelVersion: ""
|
||||
property string distribution: ""
|
||||
property string hostname: ""
|
||||
property string architecture: ""
|
||||
property string loadAverage: ""
|
||||
property int processCount: 0
|
||||
property int threadCount: 0
|
||||
property string bootTime: ""
|
||||
property string motherboard: ""
|
||||
property string biosVersion: ""
|
||||
|
||||
property int historySize: 60
|
||||
property var cpuHistory: []
|
||||
property var memoryHistory: []
|
||||
property var networkHistory: ({ "rx": [], "tx": [] })
|
||||
property var diskHistory: ({ "read": [], "write": [] })
|
||||
|
||||
function addRef(modules = null) {
|
||||
refCount++
|
||||
let modulesChanged = false
|
||||
|
||||
if (modules) {
|
||||
const modulesToAdd = Array.isArray(modules) ? modules : [modules]
|
||||
for (const module of modulesToAdd) {
|
||||
// Increment reference count for this module
|
||||
const currentCount = moduleRefCounts[module] || 0
|
||||
moduleRefCounts[module] = currentCount + 1
|
||||
console.log("Adding ref for module:", module, "count:", moduleRefCounts[module])
|
||||
|
||||
// Add to enabled modules if not already there
|
||||
if (enabledModules.indexOf(module) === -1) {
|
||||
enabledModules.push(module)
|
||||
modulesChanged = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modulesChanged || refCount === 1) {
|
||||
enabledModules = enabledModules.slice() // Force property change
|
||||
moduleRefCounts = Object.assign({}, moduleRefCounts) // Force property change
|
||||
updateAllStats()
|
||||
} else if (gpuPciIds.length > 0 && refCount > 0) {
|
||||
// If we have GPU PCI IDs and active modules, make sure to update
|
||||
// This handles the case where PCI IDs were loaded after modules were added
|
||||
updateAllStats()
|
||||
}
|
||||
}
|
||||
|
||||
function removeRef(modules = null) {
|
||||
refCount = Math.max(0, refCount - 1)
|
||||
let modulesChanged = false
|
||||
|
||||
if (modules) {
|
||||
const modulesToRemove = Array.isArray(modules) ? modules : [modules]
|
||||
for (const module of modulesToRemove) {
|
||||
const currentCount = moduleRefCounts[module] || 0
|
||||
if (currentCount > 1) {
|
||||
// Decrement reference count
|
||||
moduleRefCounts[module] = currentCount - 1
|
||||
console.log("Removing ref for module:", module, "count:", moduleRefCounts[module])
|
||||
} else if (currentCount === 1) {
|
||||
// Remove completely when count reaches 0
|
||||
delete moduleRefCounts[module]
|
||||
const index = enabledModules.indexOf(module)
|
||||
if (index > -1) {
|
||||
enabledModules.splice(index, 1)
|
||||
modulesChanged = true
|
||||
console.log("Disabling module:", module, "(no more refs)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modulesChanged) {
|
||||
enabledModules = enabledModules.slice() // Force property change
|
||||
moduleRefCounts = Object.assign({}, moduleRefCounts) // Force property change
|
||||
}
|
||||
}
|
||||
|
||||
function setGpuPciIds(pciIds) {
|
||||
gpuPciIds = Array.isArray(pciIds) ? pciIds : []
|
||||
}
|
||||
|
||||
function addGpuPciId(pciId) {
|
||||
const currentCount = gpuPciIdRefCounts[pciId] || 0
|
||||
gpuPciIdRefCounts[pciId] = currentCount + 1
|
||||
|
||||
// Add to gpuPciIds array if not already there
|
||||
if (!gpuPciIds.includes(pciId)) {
|
||||
gpuPciIds = gpuPciIds.concat([pciId])
|
||||
}
|
||||
|
||||
console.log("Adding GPU PCI ID ref:", pciId, "count:", gpuPciIdRefCounts[pciId])
|
||||
// Force property change notification
|
||||
gpuPciIdRefCounts = Object.assign({}, gpuPciIdRefCounts)
|
||||
}
|
||||
|
||||
function removeGpuPciId(pciId) {
|
||||
const currentCount = gpuPciIdRefCounts[pciId] || 0
|
||||
if (currentCount > 1) {
|
||||
// Decrement reference count
|
||||
gpuPciIdRefCounts[pciId] = currentCount - 1
|
||||
console.log("Removing GPU PCI ID ref:", pciId, "count:", gpuPciIdRefCounts[pciId])
|
||||
} else if (currentCount === 1) {
|
||||
// Remove completely when count reaches 0
|
||||
delete gpuPciIdRefCounts[pciId]
|
||||
const index = gpuPciIds.indexOf(pciId)
|
||||
if (index > -1) {
|
||||
gpuPciIds = gpuPciIds.slice()
|
||||
gpuPciIds.splice(index, 1)
|
||||
}
|
||||
|
||||
// Clear temperature data for this GPU when no longer monitored
|
||||
if (availableGpus && availableGpus.length > 0) {
|
||||
const updatedGpus = availableGpus.slice()
|
||||
for (let i = 0; i < updatedGpus.length; i++) {
|
||||
if (updatedGpus[i].pciId === pciId) {
|
||||
updatedGpus[i] = Object.assign({}, updatedGpus[i], { temperature: 0 })
|
||||
}
|
||||
}
|
||||
availableGpus = updatedGpus
|
||||
}
|
||||
|
||||
console.log("Removing GPU PCI ID completely:", pciId)
|
||||
}
|
||||
|
||||
// Force property change notification
|
||||
gpuPciIdRefCounts = Object.assign({}, gpuPciIdRefCounts)
|
||||
}
|
||||
|
||||
function setProcessOptions(limit = 20, sort = "cpu", disableCpu = false) {
|
||||
processLimit = limit
|
||||
processSort = sort
|
||||
noCpu = disableCpu
|
||||
}
|
||||
|
||||
function updateAllStats() {
|
||||
if (dankgopAvailable && refCount > 0 && enabledModules.length > 0) {
|
||||
isUpdating = true
|
||||
dankgopProcess.running = true
|
||||
} else {
|
||||
isUpdating = false
|
||||
}
|
||||
}
|
||||
|
||||
function initializeGpuMetadata() {
|
||||
if (!dankgopAvailable) return
|
||||
// Load GPU metadata once at startup for basic info
|
||||
gpuInitProcess.running = true
|
||||
}
|
||||
|
||||
function buildDankgopCommand() {
|
||||
const cmd = ["dankgop", "meta", "--json"]
|
||||
|
||||
if (enabledModules.length === 0) {
|
||||
// Don't run if no modules are needed
|
||||
return []
|
||||
}
|
||||
|
||||
// Replace 'gpu' with 'gpu-temp' when we have PCI IDs to monitor
|
||||
const finalModules = []
|
||||
for (const module of enabledModules) {
|
||||
if (module === "gpu" && gpuPciIds.length > 0) {
|
||||
finalModules.push("gpu-temp")
|
||||
} else if (module !== "gpu") {
|
||||
finalModules.push(module)
|
||||
}
|
||||
}
|
||||
|
||||
// Add gpu-temp module automatically when we have PCI IDs to monitor
|
||||
if (gpuPciIds.length > 0 && finalModules.indexOf("gpu-temp") === -1) {
|
||||
finalModules.push("gpu-temp")
|
||||
}
|
||||
|
||||
if (enabledModules.indexOf("all") !== -1) {
|
||||
cmd.push("--modules", "all")
|
||||
} else if (finalModules.length > 0) {
|
||||
const moduleList = finalModules.join(",")
|
||||
cmd.push("--modules", moduleList)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
|
||||
if (gpuPciIds.length > 0) {
|
||||
cmd.push("--gpu-pci-ids", gpuPciIds.join(","))
|
||||
}
|
||||
|
||||
if (enabledModules.indexOf("processes") !== -1 || enabledModules.indexOf("all") !== -1) {
|
||||
if (processLimit > 0) {
|
||||
cmd.push("--limit", processLimit.toString())
|
||||
}
|
||||
cmd.push("--sort", processSort)
|
||||
if (noCpu) {
|
||||
cmd.push("--no-cpu")
|
||||
}
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
function parseData(data) {
|
||||
if (data.cpu) {
|
||||
const cpu = data.cpu
|
||||
cpuUsage = cpu.usage || 0
|
||||
cpuFrequency = cpu.frequency || 0
|
||||
cpuTemperature = cpu.temperature || 0
|
||||
cpuCores = cpu.count || 1
|
||||
cpuModel = cpu.model || ""
|
||||
perCoreCpuUsage = cpu.coreUsage || []
|
||||
addToHistory(cpuHistory, cpuUsage)
|
||||
}
|
||||
|
||||
if (data.memory) {
|
||||
const mem = data.memory
|
||||
const totalKB = mem.total || 0
|
||||
const availableKB = mem.available || 0
|
||||
const freeKB = mem.free || 0
|
||||
|
||||
// Update MB properties
|
||||
totalMemoryMB = totalKB / 1024
|
||||
availableMemoryMB = availableKB / 1024
|
||||
freeMemoryMB = freeKB / 1024
|
||||
usedMemoryMB = totalMemoryMB - availableMemoryMB
|
||||
memoryUsage = totalKB > 0 ? ((totalKB - availableKB) / totalKB) * 100 : 0
|
||||
|
||||
// Update KB properties for compatibility
|
||||
totalMemoryKB = totalKB
|
||||
usedMemoryKB = totalKB - availableKB
|
||||
totalSwapKB = mem.swaptotal || 0
|
||||
usedSwapKB = (mem.swaptotal || 0) - (mem.swapfree || 0)
|
||||
|
||||
addToHistory(memoryHistory, memoryUsage)
|
||||
}
|
||||
|
||||
if (data.network && Array.isArray(data.network)) {
|
||||
// Store raw network interface data
|
||||
networkInterfaces = data.network
|
||||
|
||||
let totalRx = 0
|
||||
let totalTx = 0
|
||||
for (const iface of data.network) {
|
||||
totalRx += iface.rx || 0
|
||||
totalTx += iface.tx || 0
|
||||
}
|
||||
|
||||
if (lastNetworkStats) {
|
||||
const timeDiff = updateInterval / 1000
|
||||
const rxDiff = totalRx - lastNetworkStats.rx
|
||||
const txDiff = totalTx - lastNetworkStats.tx
|
||||
networkRxRate = Math.max(0, rxDiff / timeDiff)
|
||||
networkTxRate = Math.max(0, txDiff / timeDiff)
|
||||
addToHistory(networkHistory.rx, networkRxRate / 1024)
|
||||
addToHistory(networkHistory.tx, networkTxRate / 1024)
|
||||
}
|
||||
lastNetworkStats = { "rx": totalRx, "tx": totalTx }
|
||||
}
|
||||
|
||||
if (data.disk && Array.isArray(data.disk)) {
|
||||
// Store raw disk device data
|
||||
diskDevices = data.disk
|
||||
|
||||
let totalRead = 0
|
||||
let totalWrite = 0
|
||||
for (const disk of data.disk) {
|
||||
totalRead += (disk.read || 0) * 512
|
||||
totalWrite += (disk.write || 0) * 512
|
||||
}
|
||||
|
||||
if (lastDiskStats) {
|
||||
const timeDiff = updateInterval / 1000
|
||||
const readDiff = totalRead - lastDiskStats.read
|
||||
const writeDiff = totalWrite - lastDiskStats.write
|
||||
diskReadRate = Math.max(0, readDiff / timeDiff)
|
||||
diskWriteRate = Math.max(0, writeDiff / timeDiff)
|
||||
addToHistory(diskHistory.read, diskReadRate / (1024 * 1024))
|
||||
addToHistory(diskHistory.write, diskWriteRate / (1024 * 1024))
|
||||
}
|
||||
lastDiskStats = { "read": totalRead, "write": totalWrite }
|
||||
}
|
||||
|
||||
if (data.diskmounts) {
|
||||
diskMounts = data.diskmounts || []
|
||||
}
|
||||
|
||||
if (data.processes && Array.isArray(data.processes)) {
|
||||
const newProcesses = []
|
||||
for (const proc of data.processes) {
|
||||
newProcesses.push({
|
||||
"pid": proc.pid || 0,
|
||||
"ppid": proc.ppid || 0,
|
||||
"cpu": proc.cpu || 0,
|
||||
"memoryPercent": proc.memoryPercent || proc.pssPercent || 0,
|
||||
"memoryKB": proc.memoryKB || proc.pssKB || 0,
|
||||
"command": proc.command || "",
|
||||
"fullCommand": proc.fullCommand || "",
|
||||
"displayName": (proc.command && proc.command.length > 15) ?
|
||||
proc.command.substring(0, 15) + "..." : (proc.command || "")
|
||||
})
|
||||
}
|
||||
processes = newProcesses
|
||||
}
|
||||
|
||||
// Handle both gpu and gpu-temp module data
|
||||
const gpuData = (data.gpu && data.gpu.gpus) || data.gpus // Handle both meta format and direct gpu command format
|
||||
if (gpuData && Array.isArray(gpuData)) {
|
||||
// Check if this is temperature update data (has PCI IDs being monitored)
|
||||
if (gpuPciIds.length > 0 && availableGpus && availableGpus.length > 0) {
|
||||
// This is temperature data - merge with existing GPU metadata
|
||||
const updatedGpus = availableGpus.slice()
|
||||
for (let i = 0; i < updatedGpus.length; i++) {
|
||||
const existingGpu = updatedGpus[i]
|
||||
const tempGpu = gpuData.find(g => g.pciId === existingGpu.pciId)
|
||||
// Only update temperature if this GPU's PCI ID is being monitored
|
||||
if (tempGpu && gpuPciIds.includes(existingGpu.pciId)) {
|
||||
updatedGpus[i] = Object.assign({}, existingGpu, { temperature: tempGpu.temperature || 0 })
|
||||
}
|
||||
}
|
||||
availableGpus = updatedGpus
|
||||
} else {
|
||||
// This is initial GPU metadata - set the full list
|
||||
const gpuList = []
|
||||
for (const gpu of gpuData) {
|
||||
let displayName = gpu.displayName || gpu.name || "Unknown GPU"
|
||||
let fullName = gpu.fullName || gpu.name || "Unknown GPU"
|
||||
|
||||
gpuList.push({
|
||||
"driver": gpu.driver || "",
|
||||
"vendor": gpu.vendor || "",
|
||||
"displayName": displayName,
|
||||
"fullName": fullName,
|
||||
"pciId": gpu.pciId || "",
|
||||
"temperature": gpu.temperature || 0
|
||||
})
|
||||
}
|
||||
availableGpus = gpuList
|
||||
}
|
||||
}
|
||||
|
||||
if (data.system) {
|
||||
const sys = data.system
|
||||
loadAverage = sys.loadavg || ""
|
||||
processCount = sys.processes || 0
|
||||
threadCount = sys.threads || 0
|
||||
bootTime = sys.boottime || ""
|
||||
}
|
||||
|
||||
if (data.hardware) {
|
||||
const hw = data.hardware
|
||||
hostname = hw.hostname || ""
|
||||
kernelVersion = hw.kernel || ""
|
||||
distribution = hw.distro || ""
|
||||
architecture = hw.arch || ""
|
||||
motherboard = (hw.bios && hw.bios.motherboard) || ""
|
||||
biosVersion = (hw.bios && hw.bios.version) || ""
|
||||
}
|
||||
|
||||
isUpdating = false
|
||||
}
|
||||
|
||||
function addToHistory(array, value) {
|
||||
array.push(value)
|
||||
if (array.length > historySize) {
|
||||
array.shift()
|
||||
}
|
||||
}
|
||||
|
||||
function getProcessIcon(command) {
|
||||
const cmd = command.toLowerCase()
|
||||
if (cmd.includes("firefox") || cmd.includes("chrome") || cmd.includes("browser"))
|
||||
return "web"
|
||||
if (cmd.includes("code") || cmd.includes("editor") || cmd.includes("vim"))
|
||||
return "code"
|
||||
if (cmd.includes("terminal") || cmd.includes("bash") || cmd.includes("zsh"))
|
||||
return "terminal"
|
||||
if (cmd.includes("music") || cmd.includes("audio") || cmd.includes("spotify"))
|
||||
return "music_note"
|
||||
if (cmd.includes("video") || cmd.includes("vlc") || cmd.includes("mpv"))
|
||||
return "play_circle"
|
||||
if (cmd.includes("systemd") || cmd.includes("kernel") || cmd.includes("kthread"))
|
||||
return "settings"
|
||||
return "memory"
|
||||
}
|
||||
|
||||
function formatCpuUsage(cpu) {
|
||||
return (cpu || 0).toFixed(1) + "%"
|
||||
}
|
||||
|
||||
function formatMemoryUsage(memoryKB) {
|
||||
const mem = memoryKB || 0
|
||||
if (mem < 1024)
|
||||
return mem.toFixed(0) + " KB"
|
||||
else if (mem < 1024 * 1024)
|
||||
return (mem / 1024).toFixed(1) + " MB"
|
||||
else
|
||||
return (mem / (1024 * 1024)).toFixed(1) + " GB"
|
||||
}
|
||||
|
||||
function formatSystemMemory(memoryKB) {
|
||||
const mem = memoryKB || 0
|
||||
if (mem === 0)
|
||||
return "--"
|
||||
if (mem < 1024 * 1024)
|
||||
return (mem / 1024).toFixed(0) + " MB"
|
||||
else
|
||||
return (mem / (1024 * 1024)).toFixed(1) + " GB"
|
||||
}
|
||||
|
||||
function killProcess(pid) {
|
||||
if (pid > 0) {
|
||||
Quickshell.execDetached("kill", [pid.toString()])
|
||||
}
|
||||
}
|
||||
|
||||
function setSortBy(newSortBy) {
|
||||
if (newSortBy !== processSort) {
|
||||
processSort = newSortBy
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: updateTimer
|
||||
interval: root.updateInterval
|
||||
running: root.dankgopAvailable && root.refCount > 0 && root.enabledModules.length > 0
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: root.updateAllStats()
|
||||
}
|
||||
|
||||
Process {
|
||||
id: dankgopProcess
|
||||
command: root.buildDankgopCommand()
|
||||
running: false
|
||||
onCommandChanged: {
|
||||
console.log("DankgopService command:", JSON.stringify(command))
|
||||
}
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
console.warn("Dankgop process failed with exit code:", exitCode)
|
||||
isUpdating = false
|
||||
}
|
||||
}
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text.trim()) {
|
||||
try {
|
||||
const data = JSON.parse(text.trim())
|
||||
parseData(data)
|
||||
} catch (e) {
|
||||
console.warn("Failed to parse dankgop JSON:", e)
|
||||
console.warn("Raw text was:", text.substring(0, 200))
|
||||
isUpdating = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: gpuInitProcess
|
||||
command: ["dankgop", "gpu", "--json"]
|
||||
running: false
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
console.warn("GPU init process failed with exit code:", exitCode)
|
||||
}
|
||||
}
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text.trim()) {
|
||||
try {
|
||||
const data = JSON.parse(text.trim())
|
||||
parseData(data)
|
||||
} catch (e) {
|
||||
console.warn("Failed to parse GPU init JSON:", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: dankgopCheckProcess
|
||||
command: ["which", "dankgop"]
|
||||
running: false
|
||||
onExited: exitCode => {
|
||||
dankgopAvailable = (exitCode === 0)
|
||||
if (dankgopAvailable) {
|
||||
initializeGpuMetadata()
|
||||
// Load persisted GPU PCI IDs from session state
|
||||
if (SessionData.enabledGpuPciIds && SessionData.enabledGpuPciIds.length > 0) {
|
||||
for (const pciId of SessionData.enabledGpuPciIds) {
|
||||
addGpuPciId(pciId)
|
||||
}
|
||||
// Trigger update if we already have active modules
|
||||
if (refCount > 0 && enabledModules.length > 0) {
|
||||
updateAllStats()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn("dankgop is not installed or not in PATH")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
dankgopCheckProcess.running = true
|
||||
}
|
||||
}
|
||||
@@ -1,640 +0,0 @@
|
||||
pragma Singleton
|
||||
|
||||
pragma ComponentBehavior
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property string shellDir: Qt.resolvedUrl(".").toString().replace(
|
||||
"file://", "").replace("/Services/", "")
|
||||
|
||||
property int refCount: 0
|
||||
property int updateInterval: refCount > 0 ? 3000 : 30000
|
||||
property int maxProcesses: 100
|
||||
property bool isUpdating: false
|
||||
property bool staticDataInitialized: false
|
||||
|
||||
property var processes: []
|
||||
property string sortBy: "cpu"
|
||||
property bool sortDescending: true
|
||||
property var lastProcTicks: ({})
|
||||
property real lastTotalJiffies: -1
|
||||
|
||||
property real cpuUsage: 0
|
||||
property real totalCpuUsage: 0
|
||||
property int cpuCores: 1
|
||||
property int cpuCount: 1
|
||||
property string cpuModel: ""
|
||||
property real cpuFrequency: 0
|
||||
property real cpuTemperature: -1
|
||||
property var perCoreCpuUsage: []
|
||||
|
||||
property var lastCpuStats: null
|
||||
property var lastPerCoreStats: null
|
||||
|
||||
property real memoryUsage: 0
|
||||
property real totalMemoryMB: 0
|
||||
property real usedMemoryMB: 0
|
||||
property real freeMemoryMB: 0
|
||||
property real availableMemoryMB: 0
|
||||
property int totalMemoryKB: 0
|
||||
property int usedMemoryKB: 0
|
||||
property int totalSwapKB: 0
|
||||
property int usedSwapKB: 0
|
||||
|
||||
property real networkRxRate: 0
|
||||
property real networkTxRate: 0
|
||||
property var lastNetworkStats: null
|
||||
|
||||
property real diskReadRate: 0
|
||||
property real diskWriteRate: 0
|
||||
property var lastDiskStats: null
|
||||
property var diskMounts: []
|
||||
|
||||
property int historySize: 60
|
||||
property var cpuHistory: []
|
||||
property var memoryHistory: []
|
||||
property var networkHistory: ({
|
||||
"rx": [],
|
||||
"tx": []
|
||||
})
|
||||
property var diskHistory: ({
|
||||
"read": [],
|
||||
"write": []
|
||||
})
|
||||
|
||||
property string kernelVersion: ""
|
||||
property string distribution: ""
|
||||
property string hostname: ""
|
||||
property string architecture: ""
|
||||
property string loadAverage: ""
|
||||
property int processCount: 0
|
||||
property int threadCount: 0
|
||||
property string bootTime: ""
|
||||
property string motherboard: ""
|
||||
property string biosVersion: ""
|
||||
property var availableGpus: []
|
||||
|
||||
// Properties to control GPU temperature collection - set externally by shell.qml
|
||||
property bool gpuTempEnabled: false
|
||||
property bool nvidiaGpuTempEnabled: false
|
||||
property bool nonNvidiaGpuTempEnabled: false
|
||||
|
||||
function addRef() {
|
||||
refCount++
|
||||
if (refCount === 1) {
|
||||
if (!staticDataInitialized) {
|
||||
initializeStaticData()
|
||||
}
|
||||
updateAllStats()
|
||||
}
|
||||
}
|
||||
|
||||
function removeRef() {
|
||||
refCount = Math.max(0, refCount - 1)
|
||||
}
|
||||
|
||||
function initializeStaticData() {
|
||||
if (!staticDataInitialized) {
|
||||
staticDataInitialized = true
|
||||
staticDataProcess.running = true
|
||||
}
|
||||
}
|
||||
|
||||
function updateAllStats() {
|
||||
if (refCount > 0) {
|
||||
isUpdating = true
|
||||
dynamicStatsProcess.running = true
|
||||
}
|
||||
}
|
||||
|
||||
function setSortBy(newSortBy) {
|
||||
if (newSortBy !== sortBy) {
|
||||
sortBy = newSortBy
|
||||
sortProcessesInPlace()
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSortOrder() {
|
||||
sortDescending = !sortDescending
|
||||
sortProcessesInPlace()
|
||||
}
|
||||
|
||||
function sortProcessesInPlace() {
|
||||
if (processes.length === 0)
|
||||
return
|
||||
const sortedProcesses = [...processes]
|
||||
|
||||
sortedProcesses.sort((a, b) => {
|
||||
let aVal, bVal
|
||||
|
||||
switch (sortBy) {
|
||||
case "cpu":
|
||||
aVal = parseFloat(a.cpu) || 0
|
||||
bVal = parseFloat(b.cpu) || 0
|
||||
break
|
||||
case "memory":
|
||||
aVal = parseFloat(a.memoryPercent) || 0
|
||||
bVal = parseFloat(b.memoryPercent) || 0
|
||||
break
|
||||
case "name":
|
||||
aVal = a.command || ""
|
||||
bVal = b.command || ""
|
||||
break
|
||||
case "pid":
|
||||
aVal = parseInt(a.pid) || 0
|
||||
bVal = parseInt(b.pid) || 0
|
||||
break
|
||||
default:
|
||||
aVal = parseFloat(a.cpu) || 0
|
||||
bVal = parseFloat(b.cpu) || 0
|
||||
}
|
||||
|
||||
if (typeof aVal === "string") {
|
||||
return sortDescending ? bVal.localeCompare(
|
||||
aVal) : aVal.localeCompare(
|
||||
bVal)
|
||||
} else {
|
||||
return sortDescending ? bVal - aVal : aVal - bVal
|
||||
}
|
||||
})
|
||||
|
||||
processes = sortedProcesses
|
||||
}
|
||||
|
||||
function killProcess(pid) {
|
||||
if (pid > 0) {
|
||||
Quickshell.execDetached("kill", [pid.toString()])
|
||||
}
|
||||
}
|
||||
|
||||
function addToHistory(array, value) {
|
||||
array.push(value)
|
||||
if (array.length > historySize)
|
||||
array.shift()
|
||||
}
|
||||
|
||||
function calculateCpuUsage(currentStats, lastStats) {
|
||||
if (!lastStats || !currentStats || currentStats.length < 4) {
|
||||
return 0
|
||||
}
|
||||
|
||||
const currentTotal = currentStats.reduce((sum, val) => sum + val, 0)
|
||||
const lastTotal = lastStats.reduce((sum, val) => sum + val, 0)
|
||||
|
||||
const totalDiff = currentTotal - lastTotal
|
||||
if (totalDiff <= 0)
|
||||
return 0
|
||||
|
||||
const currentIdle = currentStats[3]
|
||||
const lastIdle = lastStats[3]
|
||||
const idleDiff = currentIdle - lastIdle
|
||||
|
||||
const usedDiff = totalDiff - idleDiff
|
||||
return Math.max(0, Math.min(100, (usedDiff / totalDiff) * 100))
|
||||
}
|
||||
|
||||
function parseStaticData(data) {
|
||||
if (data.cpu) {
|
||||
cpuCores = data.cpu.count || 1
|
||||
cpuCount = data.cpu.count || 1
|
||||
cpuModel = data.cpu.model || ""
|
||||
}
|
||||
|
||||
if (data.system) {
|
||||
kernelVersion = data.system.kernel || ""
|
||||
distribution = data.system.distro || ""
|
||||
hostname = data.system.hostname || ""
|
||||
architecture = data.system.arch || ""
|
||||
motherboard = data.system.motherboard || ""
|
||||
biosVersion = data.system.bios || ""
|
||||
}
|
||||
|
||||
if (data.gpus) {
|
||||
const gpuList = []
|
||||
for (const gpu of data.gpus) {
|
||||
// Parse the display name and PCI ID from rawLine
|
||||
let displayName = ""
|
||||
let fullName = ""
|
||||
let pciId = ""
|
||||
|
||||
if (gpu.rawLine) {
|
||||
// Extract PCI ID [vvvv:dddd]
|
||||
const pciMatch = gpu.rawLine.match(/\[([0-9a-f]{4}:[0-9a-f]{4})\]/i)
|
||||
if (pciMatch) {
|
||||
pciId = pciMatch[1]
|
||||
}
|
||||
|
||||
// Remove BDF and class prefix
|
||||
let s = gpu.rawLine.replace(/^[^:]+: /, "")
|
||||
// Remove PCI ID [vvvv:dddd] and everything after
|
||||
s = s.replace(/\[[0-9a-f]{4}:[0-9a-f]{4}\].*$/i, "")
|
||||
|
||||
// Try to extract text after last ']'
|
||||
const afterBracket = s.match(/\]\s*([^\[]+)$/)
|
||||
if (afterBracket && afterBracket[1].trim()) {
|
||||
displayName = afterBracket[1].trim()
|
||||
} else {
|
||||
// Try to get last bracketed text
|
||||
const lastBracket = s.match(/\[([^\]]+)\]([^\[]*$)/)
|
||||
if (lastBracket) {
|
||||
displayName = lastBracket[1]
|
||||
} else {
|
||||
displayName = s
|
||||
}
|
||||
}
|
||||
|
||||
// Remove vendor prefixes
|
||||
displayName = displayName
|
||||
.replace(/^NVIDIA Corporation\s+/i, "")
|
||||
.replace(/^NVIDIA\s+/i, "")
|
||||
.replace(/^Advanced Micro Devices, Inc\.\s+/i, "")
|
||||
.replace(/^AMD\/ATI\s+/i, "")
|
||||
.replace(/^AMD\s+/i, "")
|
||||
.replace(/^ATI\s+/i, "")
|
||||
.replace(/^Intel Corporation\s+/i, "")
|
||||
.replace(/^Intel\s+/i, "")
|
||||
.trim()
|
||||
} else if (gpu.rawLine && gpu.rawLine.startsWith("NVIDIA")) {
|
||||
// nvidia-smi fallback case
|
||||
displayName = gpu.rawLine.replace(/^NVIDIA\s+/, "")
|
||||
} else {
|
||||
displayName = "Unknown"
|
||||
}
|
||||
|
||||
// Build full name with vendor prefix
|
||||
switch(gpu.vendor) {
|
||||
case "NVIDIA": fullName = "NVIDIA " + displayName; break
|
||||
case "AMD": fullName = "AMD " + displayName; break
|
||||
case "Intel": fullName = "Intel " + displayName; break
|
||||
default: fullName = displayName
|
||||
}
|
||||
|
||||
gpuList.push({
|
||||
"driver": gpu.driver,
|
||||
"vendor": gpu.vendor,
|
||||
"displayName": displayName,
|
||||
"fullName": fullName,
|
||||
"pciId": pciId,
|
||||
"temperature": 0,
|
||||
"hwmon": "unknown"
|
||||
})
|
||||
}
|
||||
availableGpus = gpuList
|
||||
}
|
||||
}
|
||||
|
||||
function parseDynamicStats(data) {
|
||||
updateGpuTemperatures(data.gputemps || [])
|
||||
parseUnifiedStats(JSON.stringify(data))
|
||||
}
|
||||
|
||||
function updateGpuTemperatures(tempData) {
|
||||
if (availableGpus.length === 0) return
|
||||
|
||||
if (!gpuTempEnabled || tempData.length === 0) {
|
||||
clearGpuTemperatures()
|
||||
return
|
||||
}
|
||||
|
||||
const updatedGpus = []
|
||||
for (let i = 0; i < availableGpus.length; i++) {
|
||||
const gpu = availableGpus[i]
|
||||
const tempInfo = tempData.find(t => t.driver === gpu.driver)
|
||||
if (tempInfo) {
|
||||
updatedGpus.push({
|
||||
"driver": gpu.driver,
|
||||
"vendor": gpu.vendor,
|
||||
"displayName": gpu.displayName,
|
||||
"fullName": gpu.fullName,
|
||||
"pciId": gpu.pciId,
|
||||
"temperature": tempInfo.temperature || 0,
|
||||
"hwmon": tempInfo.hwmon || "unknown"
|
||||
})
|
||||
} else {
|
||||
updatedGpus.push({
|
||||
"driver": gpu.driver,
|
||||
"vendor": gpu.vendor,
|
||||
"displayName": gpu.displayName,
|
||||
"fullName": gpu.fullName,
|
||||
"pciId": gpu.pciId,
|
||||
"temperature": gpu.temperature || 0,
|
||||
"hwmon": gpu.hwmon || "unknown"
|
||||
})
|
||||
}
|
||||
}
|
||||
availableGpus = updatedGpus
|
||||
}
|
||||
|
||||
function clearGpuTemperatures() {
|
||||
if (availableGpus.length === 0) return
|
||||
|
||||
const clearedGpus = []
|
||||
for (let i = 0; i < availableGpus.length; i++) {
|
||||
const gpu = availableGpus[i]
|
||||
clearedGpus.push({
|
||||
"driver": gpu.driver,
|
||||
"vendor": gpu.vendor,
|
||||
"displayName": gpu.displayName,
|
||||
"fullName": gpu.fullName,
|
||||
"pciId": gpu.pciId,
|
||||
"temperature": 0,
|
||||
"hwmon": "unknown"
|
||||
})
|
||||
}
|
||||
availableGpus = clearedGpus
|
||||
}
|
||||
|
||||
function parseUnifiedStats(text) {
|
||||
function num(x) {
|
||||
return (typeof x === "number" && !isNaN(x)) ? x : 0
|
||||
}
|
||||
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(text)
|
||||
} catch (error) {
|
||||
isUpdating = false
|
||||
return
|
||||
}
|
||||
|
||||
if (data.memory) {
|
||||
const m = data.memory
|
||||
totalMemoryKB = num(m.total)
|
||||
const free = num(m.free)
|
||||
const buf = num(m.buffers)
|
||||
const cached = num(m.cached)
|
||||
const shared = num(m.shared)
|
||||
usedMemoryKB = totalMemoryKB - free - buf - cached
|
||||
totalSwapKB = num(m.swaptotal)
|
||||
usedSwapKB = num(m.swaptotal) - num(m.swapfree)
|
||||
totalMemoryMB = totalMemoryKB / 1024
|
||||
usedMemoryMB = usedMemoryKB / 1024
|
||||
freeMemoryMB = (totalMemoryKB - usedMemoryKB) / 1024
|
||||
availableMemoryMB = num(
|
||||
m.available) ? num(
|
||||
m.available) / 1024 : (free + buf + cached) / 1024
|
||||
memoryUsage = totalMemoryKB > 0 ? (usedMemoryKB / totalMemoryKB) * 100 : 0
|
||||
}
|
||||
|
||||
if (data.cpu) {
|
||||
cpuFrequency = data.cpu.frequency || 0
|
||||
cpuTemperature = data.cpu.temperature || 0
|
||||
|
||||
if (data.cpu.total && data.cpu.total.length >= 8) {
|
||||
const currentStats = data.cpu.total
|
||||
const usage = calculateCpuUsage(currentStats, lastCpuStats)
|
||||
cpuUsage = usage
|
||||
totalCpuUsage = usage
|
||||
lastCpuStats = [...currentStats]
|
||||
}
|
||||
|
||||
if (data.cpu.cores) {
|
||||
const coreUsages = []
|
||||
for (var i = 0; i < data.cpu.cores.length; i++) {
|
||||
const currentCoreStats = data.cpu.cores[i]
|
||||
if (currentCoreStats && currentCoreStats.length >= 8) {
|
||||
let lastCoreStats = null
|
||||
if (lastPerCoreStats && lastPerCoreStats[i]) {
|
||||
lastCoreStats = lastPerCoreStats[i]
|
||||
}
|
||||
|
||||
const usage = calculateCpuUsage(currentCoreStats, lastCoreStats)
|
||||
coreUsages.push(usage)
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON.stringify(perCoreCpuUsage) !== JSON.stringify(coreUsages)) {
|
||||
perCoreCpuUsage = coreUsages
|
||||
}
|
||||
|
||||
lastPerCoreStats = data.cpu.cores.map(core => [...core])
|
||||
}
|
||||
}
|
||||
|
||||
if (data.network) {
|
||||
let totalRx = 0
|
||||
let totalTx = 0
|
||||
for (const iface of data.network) {
|
||||
totalRx += iface.rx
|
||||
totalTx += iface.tx
|
||||
}
|
||||
if (lastNetworkStats) {
|
||||
const timeDiff = updateInterval / 1000
|
||||
const rxDiff = totalRx - lastNetworkStats.rx
|
||||
const txDiff = totalTx - lastNetworkStats.tx
|
||||
networkRxRate = Math.max(0, rxDiff / timeDiff)
|
||||
networkTxRate = Math.max(0, txDiff / timeDiff)
|
||||
addToHistory(networkHistory.rx, networkRxRate / 1024)
|
||||
addToHistory(networkHistory.tx, networkTxRate / 1024)
|
||||
}
|
||||
lastNetworkStats = {
|
||||
"rx": totalRx,
|
||||
"tx": totalTx
|
||||
}
|
||||
}
|
||||
|
||||
if (data.disk) {
|
||||
let totalRead = 0
|
||||
let totalWrite = 0
|
||||
for (const disk of data.disk) {
|
||||
totalRead += disk.read * 512
|
||||
totalWrite += disk.write * 512
|
||||
}
|
||||
if (lastDiskStats) {
|
||||
const timeDiff = updateInterval / 1000
|
||||
const readDiff = totalRead - lastDiskStats.read
|
||||
const writeDiff = totalWrite - lastDiskStats.write
|
||||
diskReadRate = Math.max(0, readDiff / timeDiff)
|
||||
diskWriteRate = Math.max(0, writeDiff / timeDiff)
|
||||
addToHistory(diskHistory.read, diskReadRate / (1024 * 1024))
|
||||
addToHistory(diskHistory.write, diskWriteRate / (1024 * 1024))
|
||||
}
|
||||
lastDiskStats = {
|
||||
"read": totalRead,
|
||||
"write": totalWrite
|
||||
}
|
||||
}
|
||||
|
||||
let totalDiff = 0
|
||||
if (data.cpu && data.cpu.total && data.cpu.total.length >= 4) {
|
||||
const currentTotal = data.cpu.total.reduce((s, v) => s + v, 0)
|
||||
if (lastTotalJiffies > 0)
|
||||
totalDiff = currentTotal - lastTotalJiffies
|
||||
lastTotalJiffies = currentTotal
|
||||
}
|
||||
|
||||
if (data.processes) {
|
||||
const newProcesses = []
|
||||
for (const proc of data.processes) {
|
||||
const pid = proc.pid
|
||||
const pticks = Number(proc.pticks) || 0
|
||||
const prev = lastProcTicks[pid] ?? null
|
||||
let cpuShare = 0
|
||||
|
||||
if (prev !== null && totalDiff > 0) {
|
||||
// Per share all CPUs (matches gnome system monitor)
|
||||
//cpuShare = 100 * Math.max(0, pticks - prev) / totalDiff
|
||||
|
||||
// per-share per-core
|
||||
cpuShare = 100 * cpuCores * Math.max(0, pticks - prev) / totalDiff
|
||||
}
|
||||
|
||||
lastProcTicks[pid] = pticks // update cache
|
||||
|
||||
newProcesses.push({
|
||||
"pid": pid,
|
||||
"ppid": proc.ppid,
|
||||
"cpu": cpuShare,
|
||||
"memoryPercent": proc.pssPercent
|
||||
?? proc.memoryPercent,
|
||||
"memoryKB": proc.pssKB ?? proc.memoryKB,
|
||||
"command": proc.command,
|
||||
"fullCommand": proc.fullCommand,
|
||||
"displayName": (proc.command && proc.command.length
|
||||
> 15) ? proc.command.substring(
|
||||
0,
|
||||
15) + "..." : proc.command
|
||||
})
|
||||
}
|
||||
processes = newProcesses
|
||||
sortProcessesInPlace()
|
||||
}
|
||||
|
||||
if (data.system) {
|
||||
loadAverage = data.system.loadavg || ""
|
||||
processCount = data.system.processes || 0
|
||||
threadCount = data.system.threads || 0
|
||||
bootTime = data.system.boottime || ""
|
||||
}
|
||||
|
||||
if (data.diskmounts) {
|
||||
diskMounts = data.diskmounts
|
||||
}
|
||||
|
||||
|
||||
addToHistory(cpuHistory, cpuUsage)
|
||||
addToHistory(memoryHistory, memoryUsage)
|
||||
|
||||
isUpdating = false
|
||||
}
|
||||
|
||||
function getProcessIcon(command) {
|
||||
const cmd = command.toLowerCase()
|
||||
if (cmd.includes("firefox") || cmd.includes("chrome") || cmd.includes(
|
||||
"browser"))
|
||||
return "web"
|
||||
if (cmd.includes("code") || cmd.includes("editor") || cmd.includes("vim"))
|
||||
return "code"
|
||||
if (cmd.includes("terminal") || cmd.includes("bash") || cmd.includes("zsh"))
|
||||
return "terminal"
|
||||
if (cmd.includes("music") || cmd.includes("audio") || cmd.includes(
|
||||
"spotify"))
|
||||
return "music_note"
|
||||
if (cmd.includes("video") || cmd.includes("vlc") || cmd.includes("mpv"))
|
||||
return "play_circle"
|
||||
if (cmd.includes("systemd") || cmd.includes("kernel") || cmd.includes(
|
||||
"kthread"))
|
||||
return "settings"
|
||||
return "memory"
|
||||
}
|
||||
|
||||
function formatCpuUsage(cpu) {
|
||||
return (cpu || 0).toFixed(1) + "%"
|
||||
}
|
||||
|
||||
function formatMemoryUsage(memoryKB) {
|
||||
const mem = memoryKB || 0
|
||||
if (mem < 1024)
|
||||
return mem.toFixed(0) + " KB"
|
||||
else if (mem < 1024 * 1024)
|
||||
return (mem / 1024).toFixed(1) + " MB"
|
||||
else
|
||||
return (mem / (1024 * 1024)).toFixed(1) + " GB"
|
||||
}
|
||||
|
||||
function formatSystemMemory(memoryKB) {
|
||||
const mem = memoryKB || 0
|
||||
if (mem < 1024 * 1024)
|
||||
return (mem / 1024).toFixed(0) + " MB"
|
||||
else
|
||||
return (mem / (1024 * 1024)).toFixed(1) + " GB"
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: updateTimer
|
||||
interval: root.updateInterval
|
||||
running: root.refCount > 0
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: root.updateAllStats()
|
||||
}
|
||||
|
||||
Process {
|
||||
id: staticDataProcess
|
||||
command: [root.shellDir + "/sysmon_static.sh"]
|
||||
running: false
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
console.warn("Static data collection failed with exit code:", exitCode)
|
||||
}
|
||||
}
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text.trim()) {
|
||||
const fullText = text.trim()
|
||||
const lastBraceIndex = fullText.lastIndexOf('}')
|
||||
if (lastBraceIndex === -1) {
|
||||
console.warn("Invalid static data JSON")
|
||||
return
|
||||
}
|
||||
const jsonText = fullText.substring(0, lastBraceIndex + 1)
|
||||
|
||||
try {
|
||||
const data = JSON.parse(jsonText)
|
||||
parseStaticData(data)
|
||||
} catch (e) {
|
||||
console.warn("Failed to parse static data JSON:", e)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: dynamicStatsProcess
|
||||
command: [root.shellDir + "/sysmon_dynamic_lite.sh", root.sortBy, String(root.maxProcesses), root.gpuTempEnabled ? "1" : "0", root.nvidiaGpuTempEnabled ? "1" : "0", root.nonNvidiaGpuTempEnabled ? "1" : "0"]
|
||||
running: false
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0) {
|
||||
isUpdating = false
|
||||
}
|
||||
}
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (text.trim()) {
|
||||
const fullText = text.trim()
|
||||
const lastBraceIndex = fullText.lastIndexOf('}')
|
||||
if (lastBraceIndex === -1) {
|
||||
isUpdating = false
|
||||
return
|
||||
}
|
||||
const jsonText = fullText.substring(0, lastBraceIndex + 1)
|
||||
|
||||
try {
|
||||
const data = JSON.parse(jsonText)
|
||||
parseDynamicStats(data)
|
||||
} catch (e) {
|
||||
isUpdating = false
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user