mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-11 07:52:50 -05:00
try to minimize bad data before enough cpu samples are done
This commit is contained in:
10
README.md
10
README.md
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
<div align=center>
|
<div align=center>
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ paru -S dankmaterialshell-git
|
|||||||
|
|
||||||
# Manual install
|
# Manual install
|
||||||
mkdir -p ~/.config/quickshell
|
mkdir -p ~/.config/quickshell
|
||||||
git clone https://github.com/bbedward/DankMaterialShell.git ~/.config/quickshell/DankMaterialShell
|
git clone https://github.com/AvengeMedia/DankMaterialShell.git ~/.config/quickshell/DankMaterialShell
|
||||||
qs -c DankMaterialShell
|
qs -c DankMaterialShell
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ All settings are configurable in `~/.config/DankMaterialShell/settings.json`, or
|
|||||||
|
|
||||||
**Getting help:**
|
**Getting help:**
|
||||||
|
|
||||||
- Check the [issues](https://github.com/bbedward/DankMaterialShell/issues) for known problems
|
- Check the [issues](https://github.com/AvengeMedia/DankMaterialShell/issues) for known problems
|
||||||
- Share logs from `qs -c DankMaterialShell` for debugging
|
- Share logs from `qs -c DankMaterialShell` for debugging
|
||||||
- Join the niri community for compositor-specific questions
|
- Join the niri community for compositor-specific questions
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ Singleton {
|
|||||||
// Sampling data
|
// Sampling data
|
||||||
property var cpuSampleData: null
|
property var cpuSampleData: null
|
||||||
property var procSampleData: null
|
property var procSampleData: null
|
||||||
|
property int cpuSampleCount: 0
|
||||||
|
property int processSampleCount: 0
|
||||||
|
|
||||||
property real cpuUsage: 0
|
property real cpuUsage: 0
|
||||||
property real cpuFrequency: 0
|
property real cpuFrequency: 0
|
||||||
@@ -132,6 +134,16 @@ Singleton {
|
|||||||
if (modulesChanged) {
|
if (modulesChanged) {
|
||||||
enabledModules = enabledModules.slice() // Force property change
|
enabledModules = enabledModules.slice() // Force property change
|
||||||
moduleRefCounts = Object.assign({}, moduleRefCounts) // Force property change
|
moduleRefCounts = Object.assign({}, moduleRefCounts) // Force property change
|
||||||
|
|
||||||
|
// Clear cursor data when CPU or process modules are no longer active
|
||||||
|
if (!enabledModules.includes("cpu")) {
|
||||||
|
cpuSampleData = null
|
||||||
|
cpuSampleCount = 0
|
||||||
|
}
|
||||||
|
if (!enabledModules.includes("processes")) {
|
||||||
|
procSampleData = null
|
||||||
|
processSampleCount = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,15 +279,20 @@ Singleton {
|
|||||||
function parseData(data) {
|
function parseData(data) {
|
||||||
if (data.cpu) {
|
if (data.cpu) {
|
||||||
const cpu = data.cpu
|
const cpu = data.cpu
|
||||||
cpuUsage = cpu.usage || 0
|
cpuSampleCount++
|
||||||
cpuFrequency = cpu.frequency || 0
|
|
||||||
cpuTemperature = cpu.temperature || 0
|
// Only update CPU data if we have had at least 2 samples (first sample is inaccurate)
|
||||||
cpuCores = cpu.count || 1
|
if (cpuSampleCount >= 2) {
|
||||||
cpuModel = cpu.model || ""
|
cpuUsage = cpu.usage || 0
|
||||||
perCoreCpuUsage = cpu.coreUsage || []
|
cpuFrequency = cpu.frequency || 0
|
||||||
addToHistory(cpuHistory, cpuUsage)
|
cpuTemperature = cpu.temperature || 0
|
||||||
|
cpuCores = cpu.count || 1
|
||||||
|
cpuModel = cpu.model || ""
|
||||||
|
perCoreCpuUsage = cpu.coreUsage || []
|
||||||
|
addToHistory(cpuHistory, cpuUsage)
|
||||||
|
}
|
||||||
|
|
||||||
// Update CPU sample data for the next run using cursor data
|
// Always update cursor data for next sampling
|
||||||
if (cpu.cursor) {
|
if (cpu.cursor) {
|
||||||
cpuSampleData = {
|
cpuSampleData = {
|
||||||
previousTotal: cpu.cursor.total,
|
previousTotal: cpu.cursor.total,
|
||||||
@@ -360,11 +377,16 @@ Singleton {
|
|||||||
if (data.processes && Array.isArray(data.processes)) {
|
if (data.processes && Array.isArray(data.processes)) {
|
||||||
const newProcesses = []
|
const newProcesses = []
|
||||||
const newProcSample = []
|
const newProcSample = []
|
||||||
|
processSampleCount++
|
||||||
|
|
||||||
for (const proc of data.processes) {
|
for (const proc of data.processes) {
|
||||||
|
// Only show CPU usage if we have had at least 2 samples (first sample is inaccurate)
|
||||||
|
const cpuUsage = processSampleCount >= 2 ? (proc.cpu || 0) : 0
|
||||||
|
|
||||||
newProcesses.push({
|
newProcesses.push({
|
||||||
"pid": proc.pid || 0,
|
"pid": proc.pid || 0,
|
||||||
"ppid": proc.ppid || 0,
|
"ppid": proc.ppid || 0,
|
||||||
"cpu": proc.cpu || 0,
|
"cpu": cpuUsage,
|
||||||
"memoryPercent": proc.memoryPercent || proc.pssPercent || 0,
|
"memoryPercent": proc.memoryPercent || proc.pssPercent || 0,
|
||||||
"memoryKB": proc.memoryKB || proc.pssKB || 0,
|
"memoryKB": proc.memoryKB || proc.pssKB || 0,
|
||||||
"command": proc.command || "",
|
"command": proc.command || "",
|
||||||
@@ -373,7 +395,7 @@ Singleton {
|
|||||||
proc.command.substring(0, 15) + "..." : (proc.command || "")
|
proc.command.substring(0, 15) + "..." : (proc.command || "")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Extract cursor data from pticks for next sampling call
|
// Always extract cursor data from pticks for next sampling call
|
||||||
if (proc.pid && typeof proc.pticks !== 'undefined') {
|
if (proc.pid && typeof proc.pticks !== 'undefined') {
|
||||||
newProcSample.push({
|
newProcSample.push({
|
||||||
pid: proc.pid,
|
pid: proc.pid,
|
||||||
|
|||||||
Reference in New Issue
Block a user