Compare commits

...

2 Commits

Author SHA1 Message Date
fbc799414c qs: fix actions of cavabar 2026-01-13 10:24:21 +01:00
afc7125ecf qs: fix actions of cavabar 2026-01-13 10:24:17 +01:00
7 changed files with 38 additions and 16 deletions
+2
View File
@@ -15,6 +15,8 @@ environment {
LIBVA_DRIVER_NAME "nvidia" LIBVA_DRIVER_NAME "nvidia"
__GLX_VENDOR_LIBRARY_NAME "nvidia" __GLX_VENDOR_LIBRARY_NAME "nvidia"
NVD_BACKEND "nvidia" NVD_BACKEND "nvidia"
GBM_BACKEND "nvidia-drm";
WLR_NO_HARDWARE_CURSORS "1";
// Fix Swing // Fix Swing
_JAVA_AWT_WM_NONREPARENTING "1" _JAVA_AWT_WM_NONREPARENTING "1"
@@ -4,7 +4,7 @@
"doNotDisturb": false "doNotDisturb": false
}, },
"primaryColor": "#89b4fa", "primaryColor": "#89b4fa",
"showLyricsBar": false, "showLyricsBar": true,
"sunsetDefaultEnabled": true, "sunsetDefaultEnabled": true,
"wifiEnabled": true "wifiEnabled": true
} }
@@ -3,12 +3,15 @@ import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import qs.Constants import qs.Constants
import qs.Modules.Bar.Misc import qs.Modules.Bar.Misc
import qs.Services
import qs.Utils
Item { Item {
id: root id: root
property int barWidth: 5 property int barWidth: 5
property int barSpacing: 3 property int barSpacing: 3
property int mode: 0
implicitWidth: root.barWidth * CavaBarService.count + root.barSpacing * (CavaBarService.count - 1) implicitWidth: root.barWidth * CavaBarService.count + root.barSpacing * (CavaBarService.count - 1)
implicitHeight: parent.height - 10 implicitHeight: parent.height - 10
@@ -22,7 +25,7 @@ Item {
} }
Repeater { Repeater {
model: CavaBarService.values model: mode == 2 ? Array(CavaBarService.count).fill(0.3) : CavaBarService.values
Rectangle { Rectangle {
width: root.barWidth width: root.barWidth
@@ -49,12 +52,26 @@ Item {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
onClicked: (mouse) => { onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton) if (mouse.button === Qt.LeftButton) {
MusicManager.playPause(); MusicManager.playPause();
else if (mouse.button === Qt.RightButton) } else if (mouse.button === Qt.RightButton) {
SettingsService.showLyricsBar = !SettingsService.showLyricsBar; SettingsService.showLyricsBar = !SettingsService.showLyricsBar;
else if (mouse.button === Qt.MiddleButton) } else if (mouse.button === Qt.MiddleButton) {
CavaBarService.forceEnable = !CavaBarService.forceEnable; mode = (mode + 1) % 3;
if (mode === 0) {
Logger.log("CavaBar", "Cava bar mode set to Auto");
CavaBarService.forceEnable = false;
CavaBarService.forceDisable = false;
} else if (mode === 1) {
Logger.log("CavaBar", "Cava bar mode set to Always On");
CavaBarService.forceEnable = true;
CavaBarService.forceDisable = false;
} else if (mode === 2) {
Logger.log("CavaBar", "Cava bar mode set to Always Off");
CavaBarService.forceEnable = false;
CavaBarService.forceDisable = true;
}
}
} }
onWheel: function(wheel) { onWheel: function(wheel) {
if (wheel.angleDelta.y > 0) if (wheel.angleDelta.y > 0)
@@ -7,7 +7,8 @@ Singleton {
id: root id: root
property int count: 6 property int count: 6
property int forceEnable: 6 property bool forceEnable: false
property bool forceDisable: false
property alias values: cavaProcess.values property alias values: cavaProcess.values
Cava { Cava {
@@ -15,6 +16,7 @@ Singleton {
count: root.count count: root.count
forceEnable: root.forceEnable forceEnable: root.forceEnable
forceDisable: root.forceDisable
} }
} }
@@ -32,12 +32,13 @@ Scope {
}) })
property var values: Array(count).fill(0) property var values: Array(count).fill(0)
property bool forceEnable: false property bool forceEnable: false
property bool forceDisable: false
Process { Process {
id: process id: process
stdinEnabled: true stdinEnabled: true
running: root.forceEnable || !MusicManager.isAllPaused() running: !root.forceDisable && (MusicManager.isPlaying || root.forceEnable)
command: ["cava", "-p", "/dev/stdin"] command: ["cava", "-p", "/dev/stdin"]
onExited: { onExited: {
stdinEnabled = true; stdinEnabled = true;
@@ -14,6 +14,8 @@ import subprocess
from pathlib import Path from pathlib import Path
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
MAX_WORKERS = 8
PALETTES = { PALETTES = {
"catppuccin-mocha": { "catppuccin-mocha": {
"rosewater": "f5e0dc", "rosewater": "f5e0dc",
@@ -45,9 +47,7 @@ SCRIPTS = {
"nwg-look": [CONFIG_DIR / "nwg-look" / "apply-color"], "nwg-look": [CONFIG_DIR / "nwg-look" / "apply-color"],
"mako": [CONFIG_DIR / "mako" / "apply-color"], "mako": [CONFIG_DIR / "mako" / "apply-color"],
"niri": [CONFIG_DIR / "niri" / "apply-color"], "niri": [CONFIG_DIR / "niri" / "apply-color"],
"oh-my-posh": [ "oh-my-posh": [CONFIG_DIR / "fish" / "apply-color-omp"], # borrowing fish's directory
CONFIG_DIR / "fish" / "apply-color-omp"
], # borrowing fish's directory
"quickshell": [CONFIG_DIR / "quickshell" / "apply-color"], "quickshell": [CONFIG_DIR / "quickshell" / "apply-color"],
"rofi": [CONFIG_DIR / "rofi" / "apply-color"], "rofi": [CONFIG_DIR / "rofi" / "apply-color"],
"waybar": [CONFIG_DIR / "waybar" / "apply-color"], "waybar": [CONFIG_DIR / "waybar" / "apply-color"],
@@ -57,8 +57,8 @@ SCRIPTS = {
], ],
"yazi": [CONFIG_DIR / "yazi" / "apply-color"], "yazi": [CONFIG_DIR / "yazi" / "apply-color"],
} }
# or simply `find -L ${CONFIG_DIR} -type f -iname 'apply-color*'` to get all available scripts, # or simply `find [-L] <CONFIG_DIR> -type f -name 'apply-color*'` to get all available scripts,
# but I do need the exact application names anyway, so hardcoding does make some sense # but I need the exact application names anyway, so hardcoding does make some sense
def hex2rgb(hex_color: str) -> tuple[int, int, int]: def hex2rgb(hex_color: str) -> tuple[int, int, int]:
@@ -318,7 +318,7 @@ def main():
script_args = [palette_name, flavor, palette[flavor]] script_args = [palette_name, flavor, palette[flavor]]
tasks = [] tasks = []
with ThreadPoolExecutor(max_workers=8) as executor: with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
for app in apps: for app in apps:
for script in SCRIPTS[app]: for script in SCRIPTS[app]:
tasks.append(executor.submit(run_script, script, script_args)) tasks.append(executor.submit(run_script, script, script_args))
@@ -329,7 +329,7 @@ def main():
"-a", "-a",
"change-colortheme", "change-colortheme",
"Colortheme Changed", "Colortheme Changed",
f"Palette: {palette_name}\nFlavor: {flavor}", f"Palette: {palette_name}\nFlavor: {flavor}\nApplied to {len(apps)} apps",
] ]
) )