mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
Cava: Now only runs when a visualizer is in sight.
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property bool hasAudioVisualizer: false
|
||||
|
||||
// Simple timer that run once when the widget structure has changed
|
||||
// and determine if any MediaMini widget has the visualizer on
|
||||
Timer {
|
||||
id: timerCheckVisualizer
|
||||
interval: 100
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
hasAudioVisualizer = false
|
||||
const widgets = getAllWidgetInstances("MediaMini")
|
||||
for(var i=0; i<widgets.length; i++) {
|
||||
const widget = widgets[i]
|
||||
if (widget.showVisualizer) {
|
||||
hasAudioVisualizer = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Registry to store actual widget instances
|
||||
// Key format: "screenName|section|widgetId|index"
|
||||
property var widgetInstances: ({})
|
||||
@@ -20,6 +41,9 @@ Singleton {
|
||||
"index": index,
|
||||
"instance": instance
|
||||
}
|
||||
|
||||
timerCheckVisualizer.restart()
|
||||
|
||||
Logger.log("BarService", "Registered widget:", key)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ Singleton {
|
||||
"Bluetooth": bluetoothComponent,
|
||||
"Brightness": brightnessComponent,
|
||||
"Clock": clockComponent,
|
||||
"ControlCenter": controlCenterComponent,
|
||||
"CustomButton": customButtonComponent,
|
||||
"DarkMode": darkMode,
|
||||
"KeepAwake": keepAwakeComponent,
|
||||
@@ -24,9 +25,8 @@ Singleton {
|
||||
"NightLight": nightLightComponent,
|
||||
"NotificationHistory": notificationHistoryComponent,
|
||||
"PowerProfile": powerProfileComponent,
|
||||
"SessionMenu": sessionMenuComponent,
|
||||
"ScreenRecorder": screenRecorderComponent,
|
||||
"ControlCenter": controlCenterComponent,
|
||||
"SessionMenu": sessionMenuComponent,
|
||||
"Spacer": spacerComponent,
|
||||
"SystemMonitor": systemMonitorComponent,
|
||||
"Taskbar": taskbarComponent,
|
||||
|
||||
@@ -8,9 +8,9 @@ import qs.Commons
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property bool shouldRun: BarService.hasAudioVisualizer || (PanelService.getPanel("controlCenterPanel") === PanelService.openedPanel)
|
||||
property var values: Array(barsCount).fill(0)
|
||||
property int barsCount: 24
|
||||
|
||||
property var config: ({
|
||||
"general": {
|
||||
"bars": barsCount,
|
||||
@@ -37,8 +37,11 @@ Singleton {
|
||||
Process {
|
||||
id: process
|
||||
stdinEnabled: true
|
||||
running: true // Yes, cava should run at all times! Even if no mpris is available.
|
||||
running: root.shouldRun
|
||||
command: ["cava", "-p", "/dev/stdin"]
|
||||
onRunningChanged: {
|
||||
Logger.log("Cava", "Process running:", running)
|
||||
}
|
||||
onExited: {
|
||||
stdinEnabled = true
|
||||
values = Array(barsCount).fill(0)
|
||||
@@ -64,4 +67,4 @@ Singleton {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user