mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 21:45:38 -05:00
migrate to dankgop monitoring
This commit is contained in:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user