chore(cava): CavaService => SpectrumService

This commit is contained in:
Lemmy
2026-03-06 22:34:14 -05:00
parent 552543091f
commit 77de0b0ade
15 changed files with 123 additions and 105 deletions
+1 -1
View File
@@ -470,7 +470,7 @@
"audio": {
"volumeStep": 5,
"volumeOverdrive": false,
"cavaFrameRate": 30,
"spectrumFrameRate": 30,
"visualizerType": "linear",
"mprisBlacklist": [],
"preferredPlayer": "",
+16
View File
@@ -0,0 +1,16 @@
import QtQuick
QtObject {
id: root
function migrate(adapter, logger, rawJson) {
logger.i("Settings", "Migrating settings to v57 (cavaFrameRate -> spectrumFrameRate)");
if (rawJson && rawJson.audio && rawJson.audio.cavaFrameRate !== undefined) {
adapter.audio.spectrumFrameRate = rawJson.audio.cavaFrameRate;
logger.i("Settings", "Migrated cavaFrameRate:", rawJson.audio.cavaFrameRate, "-> spectrumFrameRate");
}
return true;
}
}
+3 -1
View File
@@ -28,7 +28,8 @@ QtObject {
53: migration53Component,
54: migration54Component,
55: migration55Component,
56: migration56Component
56: migration56Component,
57: migration57Component
})
// Migration components
@@ -54,4 +55,5 @@ QtObject {
property Component migration54Component: Migration54 {}
property Component migration55Component: Migration55 {}
property Component migration56Component: Migration56 {}
property Component migration57Component: Migration57 {}
}
+2 -2
View File
@@ -25,7 +25,7 @@ Singleton {
- Default cache directory: ~/.cache/noctalia
*/
readonly property alias data: adapter // Used to access via Settings.data.xxx.yyy
readonly property int settingsVersion: 56
readonly property int settingsVersion: 57
property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1"
readonly property string shellName: "noctalia"
readonly property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/"
@@ -677,7 +677,7 @@ Singleton {
property JsonObject audio: JsonObject {
property int volumeStep: 5
property bool volumeOverdrive: false
property int cavaFrameRate: 30
property int spectrumFrameRate: 30
property string visualizerType: "linear"
property list<string> mprisBlacklist: []
property string preferredPlayer: ""
+8 -8
View File
@@ -45,20 +45,20 @@ Item {
readonly property bool shouldShow: (currentVisualizerType !== "" && currentVisualizerType !== "none") && (!hideWhenIdle || MediaService.isPlaying)
// Register/unregister with CavaService based on visibility
readonly property string cavaComponentId: "bar:audiovisualizer:" + root.screen.name + ":" + root.section + ":" + root.sectionWidgetIndex
// Register/unregister with SpectrumService based on visibility
readonly property string spectrumComponentId: "bar:audiovisualizer:" + root.screen.name + ":" + root.section + ":" + root.sectionWidgetIndex
onShouldShowChanged: {
if (root.shouldShow) {
CavaService.registerComponent(root.cavaComponentId);
SpectrumService.registerComponent(root.spectrumComponentId);
} else {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
}
Component.onDestruction: {
if (root.shouldShow) {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
}
@@ -177,7 +177,7 @@ Item {
id: linearComponent
NLinearSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: root.fillColor
showMinimumSignal: true
vertical: root.isVerticalBar
@@ -189,7 +189,7 @@ Item {
id: mirroredComponent
NMirroredSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: root.fillColor
showMinimumSignal: true
vertical: root.isVerticalBar
@@ -200,7 +200,7 @@ Item {
id: waveComponent
NWaveSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: root.fillColor
showMinimumSignal: true
vertical: root.isVerticalBar
+13 -13
View File
@@ -73,31 +73,31 @@ Item {
return showArtistFirst ? (artist ? `${artist} - ${track}` : track) : (artist ? `${track} - ${artist}` : track);
}
// CavaService registration for visualizer
readonly property string cavaComponentId: "bar:mediamini:" + root.screen?.name + ":" + root.section + ":" + root.sectionWidgetIndex
readonly property bool needsCava: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && !root.isHidden
// SpectrumService registration for visualizer
readonly property string spectrumComponentId: "bar:mediamini:" + root.screen?.name + ":" + root.section + ":" + root.sectionWidgetIndex
readonly property bool needsSpectrum: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && !root.isHidden
Layout.preferredHeight: isVertical ? -1 : Style.getBarHeightForScreen(screenName)
Layout.preferredWidth: isVertical ? Style.getBarHeightForScreen(screenName) : -1
Layout.fillHeight: false
Layout.fillWidth: false
onNeedsCavaChanged: {
if (root.needsCava) {
CavaService.registerComponent(root.cavaComponentId);
onNeedsSpectrumChanged: {
if (root.needsSpectrum) {
SpectrumService.registerComponent(root.spectrumComponentId);
} else {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
}
Component.onCompleted: {
if (root.needsCava) {
CavaService.registerComponent(root.cavaComponentId);
if (root.needsSpectrum) {
SpectrumService.registerComponent(root.spectrumComponentId);
}
}
Component.onDestruction: {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
// Layout
@@ -420,7 +420,7 @@ Item {
NLinearSpectrum {
width: parent.width - Style.marginS
height: 20
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
barPosition: root.barPosition
@@ -432,7 +432,7 @@ Item {
NMirroredSpectrum {
width: parent.width - Style.marginS
height: parent.height - Style.marginS
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
@@ -443,7 +443,7 @@ Item {
NWaveSpectrum {
width: parent.width - Style.marginS
height: parent.height - Style.marginS
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
+13 -13
View File
@@ -15,26 +15,26 @@ NBox {
// Track whether we have an active media player
readonly property bool hasActivePlayer: MediaService.currentPlayer && MediaService.canPlay
// CavaService registration for visualizer
readonly property bool needsCava: Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none"
// SpectrumService registration for visualizer
readonly property bool needsSpectrum: Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none"
onNeedsCavaChanged: {
if (root.needsCava) {
CavaService.registerComponent("mediacard");
onNeedsSpectrumChanged: {
if (root.needsSpectrum) {
SpectrumService.registerComponent("mediacard");
} else {
CavaService.unregisterComponent("mediacard");
SpectrumService.unregisterComponent("mediacard");
}
}
Component.onCompleted: {
if (root.needsCava) {
CavaService.registerComponent("mediacard");
if (root.needsSpectrum) {
SpectrumService.registerComponent("mediacard");
}
updateCachedWallpaper();
}
Component.onDestruction: {
CavaService.unregisterComponent("mediacard");
SpectrumService.unregisterComponent("mediacard");
}
property string wallpaper: WallpaperService.getWallpaper(screen.name)
@@ -157,7 +157,7 @@ NBox {
id: linearComponent
NLinearSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.8
}
@@ -167,7 +167,7 @@ NBox {
id: mirroredComponent
NMirroredSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.8
}
@@ -177,7 +177,7 @@ NBox {
id: waveComponent
NWaveSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.8
}
@@ -268,7 +268,7 @@ NBox {
// No media player detected - centered disc icon
NIcon {
anchors.centerIn: parent
visible: !root.hasActivePlayer && CavaService.isIdle
visible: !root.hasActivePlayer && SpectrumService.isIdle
icon: "disc"
pointSize: Style.fontSizeXXXL * 3
color: Color.mOnSurfaceVariant
@@ -25,29 +25,29 @@ DraggableDesktopWidget {
readonly property bool shouldShow: visualizerType !== "" && visualizerType !== "none" && (!hideWhenIdle || MediaService.isPlaying)
readonly property bool isHidden: !shouldShow
readonly property bool shouldRegisterCava: shouldShow
readonly property bool shouldRegisterSpectrum: shouldShow
// Keep widget visible in edit mode so users can move/configure it
visible: !root.isHidden || DesktopWidgetRegistry.editMode
readonly property string cavaComponentId: "desktop:audiovisualizer:" + (root.screen ? root.screen.name : "unknown") + ":" + root.widgetIndex
readonly property string spectrumComponentId: "desktop:audiovisualizer:" + (root.screen ? root.screen.name : "unknown") + ":" + root.widgetIndex
onShouldRegisterCavaChanged: {
if (root.shouldRegisterCava) {
CavaService.registerComponent(root.cavaComponentId);
onShouldRegisterSpectrumChanged: {
if (root.shouldRegisterSpectrum) {
SpectrumService.registerComponent(root.spectrumComponentId);
} else {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
}
Component.onCompleted: {
if (root.shouldRegisterCava) {
CavaService.registerComponent(root.cavaComponentId);
if (root.shouldRegisterSpectrum) {
SpectrumService.registerComponent(root.spectrumComponentId);
}
}
Component.onDestruction: {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
implicitWidth: Math.round(visualizerWidth * widgetScale)
@@ -88,7 +88,7 @@ DraggableDesktopWidget {
id: linearComponent
NLinearSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: root.fillColor
showMinimumSignal: true
}
@@ -98,7 +98,7 @@ DraggableDesktopWidget {
id: mirroredComponent
NMirroredSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: root.fillColor
showMinimumSignal: true
}
@@ -108,7 +108,7 @@ DraggableDesktopWidget {
id: waveComponent
NWaveSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: root.fillColor
showMinimumSignal: true
}
@@ -32,26 +32,26 @@ DraggableDesktopWidget {
readonly property bool isHidden: (shouldHideIdle || shouldHideEmpty) && !DesktopWidgetRegistry.editMode
visible: !isHidden
// CavaService registration for visualizer
readonly property string cavaComponentId: "desktopmediaplayer:" + (root.screen ? root.screen.name : "unknown")
readonly property bool needsCava: root.shouldShowVisualizer && !root.isHidden
// SpectrumService registration for visualizer
readonly property string spectrumComponentId: "desktopmediaplayer:" + (root.screen ? root.screen.name : "unknown")
readonly property bool needsSpectrum: root.shouldShowVisualizer && !root.isHidden
onNeedsCavaChanged: {
if (root.needsCava) {
CavaService.registerComponent(root.cavaComponentId);
onNeedsSpectrumChanged: {
if (root.needsSpectrum) {
SpectrumService.registerComponent(root.spectrumComponentId);
} else {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
}
Component.onCompleted: {
if (root.needsCava) {
CavaService.registerComponent(root.cavaComponentId);
if (root.needsSpectrum) {
SpectrumService.registerComponent(root.spectrumComponentId);
}
}
Component.onDestruction: {
CavaService.unregisterComponent(root.cavaComponentId);
SpectrumService.unregisterComponent(root.spectrumComponentId);
}
readonly property bool showPrev: hasPlayer && MediaService.canGoPrevious
@@ -82,7 +82,7 @@ DraggableDesktopWidget {
anchors.bottomMargin: 0
z: 0
clip: true
active: needsCava
active: needsSpectrum
layer.enabled: true
layer.smooth: true
layer.effect: MultiEffect {
@@ -114,7 +114,7 @@ DraggableDesktopWidget {
id: linearComponent
NLinearSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.5
}
@@ -124,7 +124,7 @@ DraggableDesktopWidget {
id: mirroredComponent
NMirroredSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.5
}
@@ -134,7 +134,7 @@ DraggableDesktopWidget {
id: waveComponent
NWaveSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.5
}
+9 -9
View File
@@ -17,13 +17,13 @@ Loader {
active: false
// Track if the visualizer should be shown (lockscreen active + media playing + non-compact mode)
readonly property bool needsCava: root.active && !Settings.data.general.compactLockScreen && Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none"
readonly property bool needsSpectrum: root.active && !Settings.data.general.compactLockScreen && Settings.data.audio.visualizerType !== "" && Settings.data.audio.visualizerType !== "none"
onActiveChanged: {
if (root.active && root.needsCava) {
CavaService.registerComponent("lockscreen");
if (root.active && root.needsSpectrum) {
SpectrumService.registerComponent("lockscreen");
} else {
CavaService.unregisterComponent("lockscreen");
SpectrumService.unregisterComponent("lockscreen");
}
if (root.active) {
@@ -33,11 +33,11 @@ Loader {
}
}
onNeedsCavaChanged: {
if (root.needsCava) {
CavaService.registerComponent("lockscreen");
onNeedsSpectrumChanged: {
if (root.needsSpectrum) {
SpectrumService.registerComponent("lockscreen");
} else {
CavaService.unregisterComponent("lockscreen");
SpectrumService.unregisterComponent("lockscreen");
}
}
@@ -47,7 +47,7 @@ Loader {
}
Component.onDestruction: {
CavaService.unregisterComponent("lockscreen");
SpectrumService.unregisterComponent("lockscreen");
LockKeysService.unregisterComponent("lockscreen");
}
+3 -3
View File
@@ -268,7 +268,7 @@ Item {
z: 0
sourceComponent: NLinearSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
@@ -281,7 +281,7 @@ Item {
z: 0
sourceComponent: NMirroredSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
@@ -294,7 +294,7 @@ Item {
z: 0
sourceComponent: NWaveSpectrum {
anchors.fill: parent
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
+13 -13
View File
@@ -49,24 +49,24 @@ SmartPanel {
readonly property bool isSideBySide: root.compactMode && root.showAlbumArt
readonly property bool needsCava: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && root.isPanelOpen
readonly property bool needsSpectrum: root.showVisualizer && root.visualizerType !== "" && root.visualizerType !== "none" && root.isPanelOpen
onNeedsCavaChanged: {
if (root.needsCava) {
CavaService.registerComponent("mediaplayerpanel");
onNeedsSpectrumChanged: {
if (root.needsSpectrum) {
SpectrumService.registerComponent("mediaplayerpanel");
} else {
CavaService.unregisterComponent("mediaplayerpanel");
SpectrumService.unregisterComponent("mediaplayerpanel");
}
}
Component.onCompleted: {
if (root.needsCava) {
CavaService.registerComponent("mediaplayerpanel");
if (root.needsSpectrum) {
SpectrumService.registerComponent("mediaplayerpanel");
}
}
Component.onDestruction: {
CavaService.unregisterComponent("mediaplayerpanel");
SpectrumService.unregisterComponent("mediaplayerpanel");
}
panelContent: Item {
@@ -238,7 +238,7 @@ SmartPanel {
Loader {
anchors.fill: parent
z: 0
active: !!(root.needsCava && !root.showAlbumArt)
active: !!(root.needsSpectrum && !root.showAlbumArt)
sourceComponent: visualizerSource
}
@@ -276,7 +276,7 @@ SmartPanel {
anchors.fill: parent
anchors.margins: Style.marginS
z: 2
active: !!(root.needsCava && root.showAlbumArt)
active: !!(root.needsSpectrum && root.showAlbumArt)
sourceComponent: visualizerSource
}
}
@@ -492,7 +492,7 @@ SmartPanel {
NLinearSpectrum {
width: parent.width - Style.marginS
height: 20
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
barPosition: Settings.getBarPositionForScreen(root.screen?.name)
@@ -504,7 +504,7 @@ SmartPanel {
NMirroredSpectrum {
width: parent.width - Style.marginS
height: parent.height - Style.marginS
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
@@ -515,7 +515,7 @@ SmartPanel {
NWaveSpectrum {
width: parent.width - Style.marginS
height: parent.height - Style.marginS
values: CavaService.values
values: SpectrumService.values
fillColor: Color.mPrimary
opacity: 0.4
}
@@ -82,8 +82,8 @@ ColumnLayout {
})
}
]
currentKey: Settings.data.audio.cavaFrameRate
defaultValue: Settings.getDefaultValue("audio.cavaFrameRate")
onSelected: key => Settings.data.audio.cavaFrameRate = key
currentKey: Settings.data.audio.spectrumFrameRate
defaultValue: Settings.getDefaultValue("audio.spectrumFrameRate")
onSelected: key => Settings.data.audio.spectrumFrameRate = key
}
}
+1 -1
View File
@@ -241,7 +241,7 @@ cava)
# Reload cava if it's running, but only if it's not using stdin config
if pgrep -f cava >/dev/null; then
# Check if Cava is running with -p /dev/stdin (managed by CavaService)
# Check if Cava is running with -p /dev/stdin (standalone cava)
if ! pgrep -af cava | grep -q -- "-p.*stdin"; then
pkill -USR1 cava
fi
@@ -14,14 +14,14 @@ Singleton {
function registerComponent(componentId) {
root.registeredComponents[componentId] = true;
root.registeredComponents = Object.assign({}, root.registeredComponents);
Logger.d("Cava", "Component registered:", componentId, "- total:", root.registeredCount);
Logger.d("Spectrum", "Component registered:", componentId, "- total:", root.registeredCount);
}
// Unregister a component when it no longer needs audio data.
function unregisterComponent(componentId) {
delete root.registeredComponents[componentId];
root.registeredComponents = Object.assign({}, root.registeredComponents);
Logger.d("Cava", "Component unregistered:", componentId, "- total:", root.registeredCount);
Logger.d("Spectrum", "Component unregistered:", componentId, "- total:", root.registeredCount);
}
// Check if a component is registered
@@ -57,7 +57,7 @@ Singleton {
property var config: ({
"general": {
"bars": barsCount,
"framerate": Settings.data.audio.cavaFrameRate,
"framerate": Settings.data.audio.spectrumFrameRate,
"autosens": 1,
"sensitivity": 100,
"lower_cutoff_freq": 50,
@@ -96,7 +96,7 @@ Singleton {
repeat: false
onTriggered: {
if (root.shouldRun && !process.running) {
Logger.w("Cava", "Restarting after crash...");
Logger.w("Spectrum", "Restarting after crash...");
process.running = true;
}
}
@@ -107,7 +107,7 @@ Singleton {
stdinEnabled: true
command: ["cava", "-p", "/dev/stdin"]
onRunningChanged: {
Logger.d("Cava", "Process running:", running);
Logger.d("Spectrum", "Process running:", running);
}
onExited: {
stdinEnabled = true;
@@ -115,18 +115,18 @@ Singleton {
if (root.shouldRun) {
root._crashCount++;
if (root._crashCount <= root._maxCrashes) {
Logger.w("Cava", "Process exited unexpectedly, restarting in 2s... (attempt " + root._crashCount + "/" + root._maxCrashes + ")");
Logger.w("Spectrum", "Process exited unexpectedly, restarting in 2s... (attempt " + root._crashCount + "/" + root._maxCrashes + ")");
restartTimer.start();
} else {
Logger.e("Cava", "Process crashed too many times (" + root._maxCrashes + "), giving up");
Logger.e("Spectrum", "Process crashed too many times (" + root._maxCrashes + "), giving up");
}
} else {
Logger.d("Cava", "Process exited (no longer needed)");
Logger.d("Spectrum", "Process exited (no longer needed)");
root._crashCount = 0;
}
}
onStarted: {
Logger.d("Cava", "Process started");
Logger.d("Spectrum", "Process started");
for (const k in config) {
if (typeof config[k] !== "object") {
write(k + "=" + config[k] + "\n");
@@ -184,7 +184,7 @@ Singleton {
root.isIdle = true;
// Set all values to 0 one final time
root.values = Array(root.barsCount).fill(0);
Logger.d("Cava", "Idle detected - stopped rendering");
Logger.d("Spectrum", "Idle detected - stopped rendering");
}
// Don't update values while idle
return;
@@ -194,7 +194,7 @@ Singleton {
root.idleFrameCount = 0;
if (root.isIdle) {
root.isIdle = false;
Logger.d("Cava", "Audio detected - resumed rendering");
Logger.d("Spectrum", "Audio detected - resumed rendering");
}
}
@@ -208,7 +208,7 @@ Singleton {
stderr: StdioCollector {
onStreamFinished: {
if (text.trim()) {
Logger.w("Cava", "Error", text);
Logger.w("Spectrum", "Error", text);
}
}
}