mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 05:55:37 -05:00
ipc wallpaper handler, fix high CPU usage
This commit is contained in:
@@ -16,6 +16,10 @@ Singleton {
|
||||
property var audioSources: []
|
||||
property string currentAudioSource: ""
|
||||
|
||||
// Device scanning control
|
||||
property bool deviceScanningEnabled: false
|
||||
property bool initialScanComplete: false
|
||||
|
||||
// Real Audio Control
|
||||
Process {
|
||||
id: volumeChecker
|
||||
@@ -51,7 +55,7 @@ Singleton {
|
||||
Process {
|
||||
id: audioSinkLister
|
||||
command: ["pactl", "list", "sinks"]
|
||||
running: true
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
@@ -136,7 +140,7 @@ Singleton {
|
||||
Process {
|
||||
id: audioSourceLister
|
||||
command: ["pactl", "list", "sources"]
|
||||
running: true
|
||||
running: false
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
@@ -283,7 +287,9 @@ Singleton {
|
||||
console.log("Audio sink changed successfully")
|
||||
// Refresh current sink and list
|
||||
defaultSinkChecker.running = true
|
||||
audioSinkLister.running = true
|
||||
if (root.deviceScanningEnabled) {
|
||||
audioSinkLister.running = true
|
||||
}
|
||||
} else {
|
||||
console.error("Failed to change audio sink")
|
||||
}
|
||||
@@ -308,20 +314,51 @@ Singleton {
|
||||
console.log("Audio source changed successfully")
|
||||
// Refresh current source and list
|
||||
defaultSourceChecker.running = true
|
||||
audioSourceLister.running = true
|
||||
if (root.deviceScanningEnabled) {
|
||||
audioSourceLister.running = true
|
||||
}
|
||||
} else {
|
||||
console.error("Failed to change audio source")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Timer to refresh audio devices regularly (catches new Bluetooth devices)
|
||||
Timer {
|
||||
interval: 4000 // 4s refresh to catch new BT devices
|
||||
running: true; repeat: true
|
||||
interval: 5000
|
||||
running: root.deviceScanningEnabled && root.initialScanComplete
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (root.deviceScanningEnabled) {
|
||||
audioSinkLister.running = true
|
||||
audioSourceLister.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("AudioService: Starting initialization...")
|
||||
// Do initial device scan
|
||||
audioSinkLister.running = true
|
||||
audioSourceLister.running = true
|
||||
initialScanComplete = true
|
||||
console.log("AudioService: Initialization complete")
|
||||
}
|
||||
|
||||
// Control functions for managing device scanning
|
||||
function enableDeviceScanning(enabled) {
|
||||
console.log("AudioService: Device scanning", enabled ? "enabled" : "disabled")
|
||||
root.deviceScanningEnabled = enabled
|
||||
if (enabled && root.initialScanComplete) {
|
||||
// Immediately scan when enabled
|
||||
audioSinkLister.running = true
|
||||
audioSourceLister.running = true
|
||||
}
|
||||
}
|
||||
|
||||
// Manual refresh function for when user opens audio settings
|
||||
function refreshDevices() {
|
||||
console.log("AudioService: Manual device refresh triggered")
|
||||
audioSinkLister.running = true
|
||||
audioSourceLister.running = true
|
||||
}
|
||||
}
|
||||
@@ -193,10 +193,10 @@ Singleton {
|
||||
', root)
|
||||
}
|
||||
|
||||
// Timer to refresh adapter & device state
|
||||
Timer {
|
||||
interval: 3000 // 3s refresh for more responsive updates
|
||||
running: true; repeat: true
|
||||
id: bluetoothMonitorTimer
|
||||
interval: 5000
|
||||
running: false; repeat: true
|
||||
onTriggered: {
|
||||
bluetoothStatusChecker.running = true
|
||||
if (root.bluetoothEnabled) {
|
||||
@@ -208,6 +208,14 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function enableMonitoring(enabled) {
|
||||
bluetoothMonitorTimer.running = enabled
|
||||
if (enabled) {
|
||||
// Immediately update when enabled
|
||||
bluetoothStatusChecker.running = true
|
||||
}
|
||||
}
|
||||
|
||||
property var discoveredDevices: []
|
||||
|
||||
// Handle discovered devices
|
||||
|
||||
@@ -12,10 +12,10 @@ Singleton {
|
||||
property bool isLoading: false
|
||||
property string lastError: ""
|
||||
|
||||
// Periodic refresh timer (5 minutes)
|
||||
// Periodic refresh timer
|
||||
Timer {
|
||||
id: refreshTimer
|
||||
interval: 300000 // 5 minutes
|
||||
interval: 60000
|
||||
running: root.khalAvailable
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
|
||||
@@ -10,7 +10,10 @@ Singleton {
|
||||
// Process list properties
|
||||
property var processes: []
|
||||
property bool isUpdating: false
|
||||
property int processUpdateInterval: 3000
|
||||
property int processUpdateInterval: 1500
|
||||
|
||||
// Performance control - only run when process monitor is actually visible
|
||||
property bool monitoringEnabled: false
|
||||
|
||||
// System information properties
|
||||
property int totalMemoryKB: 0
|
||||
@@ -109,28 +112,41 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// System and process monitoring timer
|
||||
// System and process monitoring timer - now conditional
|
||||
Timer {
|
||||
id: processTimer
|
||||
interval: root.processUpdateInterval
|
||||
running: true
|
||||
running: root.monitoringEnabled // Only run when monitoring is enabled
|
||||
repeat: true
|
||||
|
||||
onTriggered: {
|
||||
updateSystemInfo()
|
||||
updateProcessList()
|
||||
if (root.monitoringEnabled) {
|
||||
updateSystemInfo()
|
||||
updateProcessList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Public functions
|
||||
function updateSystemInfo() {
|
||||
if (!systemInfoProcess.running) {
|
||||
if (!systemInfoProcess.running && root.monitoringEnabled) {
|
||||
systemInfoProcess.running = true
|
||||
}
|
||||
}
|
||||
|
||||
// Control functions for enabling/disabling monitoring
|
||||
function enableMonitoring(enabled) {
|
||||
console.log("ProcessMonitorService: Monitoring", enabled ? "enabled" : "disabled")
|
||||
root.monitoringEnabled = enabled
|
||||
if (enabled) {
|
||||
// Immediately update when enabled
|
||||
updateSystemInfo()
|
||||
updateProcessList()
|
||||
}
|
||||
}
|
||||
|
||||
function updateProcessList() {
|
||||
if (!root.isUpdating) {
|
||||
if (!root.isUpdating && root.monitoringEnabled) {
|
||||
root.isUpdating = true
|
||||
|
||||
// Update sort command based on current sort option
|
||||
|
||||
@@ -28,11 +28,14 @@ Singleton {
|
||||
// Temperature properties
|
||||
property real cpuTemperature: 0.0
|
||||
|
||||
// Update intervals
|
||||
property int cpuUpdateInterval: 1000
|
||||
property int memoryUpdateInterval: 2000
|
||||
property int temperatureUpdateInterval: 5000
|
||||
property int cpuUpdateInterval: 3000
|
||||
property int memoryUpdateInterval: 5000
|
||||
property int temperatureUpdateInterval: 10000
|
||||
|
||||
// Performance control
|
||||
property bool enabledForTopBar: true
|
||||
property bool enabledForDetailedView: false
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("SystemMonitorService: Starting initialization...")
|
||||
getCpuInfo()
|
||||
@@ -176,12 +179,14 @@ Singleton {
|
||||
Timer {
|
||||
id: cpuTimer
|
||||
interval: root.cpuUpdateInterval
|
||||
running: true
|
||||
running: root.enabledForTopBar || root.enabledForDetailedView
|
||||
repeat: true
|
||||
|
||||
onTriggered: {
|
||||
cpuUsageProcess.running = true
|
||||
cpuFrequencyProcess.running = true
|
||||
if (root.enabledForTopBar || root.enabledForDetailedView) {
|
||||
cpuUsageProcess.running = true
|
||||
cpuFrequencyProcess.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,11 +194,13 @@ Singleton {
|
||||
Timer {
|
||||
id: memoryTimer
|
||||
interval: root.memoryUpdateInterval
|
||||
running: true
|
||||
running: root.enabledForTopBar || root.enabledForDetailedView
|
||||
repeat: true
|
||||
|
||||
onTriggered: {
|
||||
memoryUsageProcess.running = true
|
||||
if (root.enabledForTopBar || root.enabledForDetailedView) {
|
||||
memoryUsageProcess.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,11 +208,13 @@ Singleton {
|
||||
Timer {
|
||||
id: temperatureTimer
|
||||
interval: root.temperatureUpdateInterval
|
||||
running: true
|
||||
running: root.enabledForDetailedView
|
||||
repeat: true
|
||||
|
||||
onTriggered: {
|
||||
temperatureProcess.running = true
|
||||
if (root.enabledForDetailedView) {
|
||||
temperatureProcess.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,10 +224,22 @@ Singleton {
|
||||
}
|
||||
|
||||
function updateSystemStats() {
|
||||
cpuUsageProcess.running = true
|
||||
memoryUsageProcess.running = true
|
||||
cpuFrequencyProcess.running = true
|
||||
temperatureProcess.running = true
|
||||
if (root.enabledForTopBar || root.enabledForDetailedView) {
|
||||
cpuUsageProcess.running = true
|
||||
memoryUsageProcess.running = true
|
||||
cpuFrequencyProcess.running = true
|
||||
if (root.enabledForDetailedView) {
|
||||
temperatureProcess.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enableTopBarMonitoring(enabled) {
|
||||
root.enabledForTopBar = enabled
|
||||
}
|
||||
|
||||
function enableDetailedMonitoring(enabled) {
|
||||
root.enabledForDetailedView = enabled
|
||||
}
|
||||
|
||||
function getCpuUsageColor() {
|
||||
@@ -245,4 +266,4 @@ Singleton {
|
||||
if (cpuTemperature > 65) return "#f39c12" // Orange
|
||||
return "#27ae60" // Green
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user