From 2e80ef1181a59265a7a76a3cd8bd5953e7259568 Mon Sep 17 00:00:00 2001 From: mx Date: Tue, 13 Oct 2026 15:30:17 +0200 Subject: [PATCH] Open wallpaper picker from launcher, apply on click, move media bar options to module cog Co-Authored-By: Claude Opus 5.5 --- quickshell/bar/modules/CavaModule.qml | 4 +- quickshell/core/ModuleRegistry.qml | 17 +++++- quickshell/core/SettingsRegistry.qml | 4 +- quickshell/launcher/CommandRegistry.qml | 3 +- quickshell/settings/controls/BarEditor.qml | 19 ++++++- quickshell/settings/pages/Media.qml | 65 ---------------------- quickshell/shell.qml | 1 + quickshell/testing/SettingsDriver.qml | 2 +- quickshell/wallpaper/WallpaperPicker.qml | 7 +-- tests/launcher_runtime.py | 6 +- 10 files changed, 49 insertions(+), 79 deletions(-) diff --git a/quickshell/bar/modules/CavaModule.qml b/quickshell/bar/modules/CavaModule.qml index e8320d3..9556377 100644 --- a/quickshell/bar/modules/CavaModule.qml +++ b/quickshell/bar/modules/CavaModule.qml @@ -6,7 +6,7 @@ import "../../services" import "../../theme" // Cava audio visualizer in the bar. Click opens the dashboard's Media tab, -// right-click the Media settings. Cava only runs while something plays. +// right-click the Bar settings (its options sit on the module cog). Cava only runs while something plays. GlassPill { id: root objectName: "cavaPill" @@ -76,7 +76,7 @@ GlassPill { } TapHandler { acceptedButtons: Qt.RightButton - onTapped: ShellState.openSettings("media") + onTapped: ShellState.openSettings("bar") } HoverHandler { cursorShape: Qt.PointingHandCursor diff --git a/quickshell/core/ModuleRegistry.qml b/quickshell/core/ModuleRegistry.qml index 43f559b..0dc2e49 100644 --- a/quickshell/core/ModuleRegistry.qml +++ b/quickshell/core/ModuleRegistry.qml @@ -47,12 +47,25 @@ Singleton { { key: "preview", label: "Hover preview", choices: ["on", "off"], fallback: "on" } ] }) + // Cog options stored outside the module entry: a config path shared by every + // layout (`setting`), or another module's enabled flag (`module`). + readonly property var sharedOptions: ({ + nowPlaying: [ + { key: "visualizer", module: "cava", label: "Visualizer", type: "boolean", description: "Cava bars beside the track; shows system audio and only runs while something plays" }, + { key: "cavaBars", setting: "bar.cava.bars", label: "Visualizer bars", type: "integer", min: 4, max: 24 }, + { key: "cavaStyle", setting: "bar.cava.style", label: "Visualizer style", type: "choice", choices: ["bars", "mirror"] }, + { key: "cavaHide", setting: "bar.cava.hideWhenIdle", label: "Hide while paused", type: "boolean" } + ], + cava: [ + { key: "cavaBars", setting: "bar.cava.bars", label: "Bars", type: "integer", min: 4, max: 24 }, + { key: "cavaStyle", setting: "bar.cava.style", label: "Style", type: "choice", choices: ["bars", "mirror"] }, + { key: "cavaHide", setting: "bar.cava.hideWhenIdle", label: "Hide while paused", type: "boolean" } + ] + }) // Modules whose options already live on a settings page: the cog jumps there. readonly property var settingsLinks: ({ clock: { page: "bar", setting: "Show date" }, workspaces: { page: "bar", setting: "Workspace style" }, - cava: { page: "media", setting: "Visualizer bars" }, - nowPlaying: { page: "media", setting: "Now playing" }, tray: { page: "tray", setting: "" }, volume: { page: "osd", setting: "Step" }, system: { page: "controlcenter", setting: "" }, diff --git a/quickshell/core/SettingsRegistry.qml b/quickshell/core/SettingsRegistry.qml index d70ebf7..b8cf5f9 100644 --- a/quickshell/core/SettingsRegistry.qml +++ b/quickshell/core/SettingsRegistry.qml @@ -39,6 +39,8 @@ Singleton { id: "wallpaper", title: "Wallpaper", command: "wallpaper", + // The launcher command opens the picker itself; the page stays reachable from its cog. + launcherAction: "openWallpaperPicker", description: "Wallpaper picker and palette generation", phase: 5, available: true, @@ -154,7 +156,7 @@ Singleton { available: true, group: "shell", icon: "󰝚", - keywords: ["Now playing", "Visualizer", "Cava", "Visualizer bars", "Visualizer style", "Hide while paused", "Album artwork", "Track progress", "Album name", "Visualizer in cards", "Preferred player"] + keywords: ["Album artwork", "Track progress", "Album name", "Visualizer in cards", "Preferred player"] }, { id: "metrics", diff --git a/quickshell/launcher/CommandRegistry.qml b/quickshell/launcher/CommandRegistry.qml index 521c815..f7f3983 100644 --- a/quickshell/launcher/CommandRegistry.qml +++ b/quickshell/launcher/CommandRegistry.qml @@ -11,7 +11,8 @@ Singleton { title: page.title, description: page.description, page: page.id, - available: page.available + available: page.available, + run: page.launcherAction ? () => ShellState[page.launcherAction]() : undefined })).concat(extensions) // Extensions are registered by trusted QML code, never interpreted from search text. function registerCommand(command) { diff --git a/quickshell/settings/controls/BarEditor.qml b/quickshell/settings/controls/BarEditor.qml index 69160e9..84b4cd9 100644 --- a/quickshell/settings/controls/BarEditor.qml +++ b/quickshell/settings/controls/BarEditor.qml @@ -23,18 +23,35 @@ Item { // manifest schema (boolean / integer / number / string / choices). function fieldsFor(id) { if (!ModuleRegistry.isPlugin(id)) - return (ModuleRegistry.optionSchemas[id] || []).map(f => Object.assign({type:"choice"}, f)); + return (ModuleRegistry.optionSchemas[id] || []).map(f => Object.assign({type:"choice"}, f)).concat(ModuleRegistry.sharedOptions[id] || []); return PluginService.schema(String(id).slice(7)).filter(f => f && f.key).map(f => { const choices = Array.isArray(f.choices) ? f.choices : Array.isArray(f.options) ? f.options.map(o => typeof o === "object" ? o.value : o) : null; return Object.assign({}, f, {label: f.label || f.key, type: choices ? "choice" : (f.type || "string"), choices: choices || []}); }); } function valueOf(entry, field) { + if (field.setting) + return ConfigService.value(field.setting); + if (field.module) + return root.modules.some(m => m.id === field.module && m.enabled); if (!ModuleRegistry.isPlugin(entry.id)) return ModuleRegistry.option(entry, field.key); return PluginService.widgetSettings(String(entry.id).slice(7), entry.options)[field.key]; } function setOption(entry, key, value) { + const field = root.fieldsFor(entry.id).find(f => f.key === key) || {}; + if (field.setting) + return ConfigService.setValue(field.setting, value); + if (field.module) { + // Toggle the companion module, adding it right after this one the first time. + if (root.modules.some(m => m.id === field.module)) + return root.save(Logic.editModule(root.modules, field.module, "enabled", value)); + if (!value) + return; + const list = root.modules.slice(); + list.splice(list.findIndex(m => m.id === entry.id) + 1, 0, {id: field.module, position: entry.position, enabled: true}); + return root.save(list); + } root.save(Logic.editModule(root.modules, entry.id, "options", Object.assign({}, entry.options || {}, {[key]: value}))); } readonly property var modules: BarLayout.modulesFor(screenName) diff --git a/quickshell/settings/pages/Media.qml b/quickshell/settings/pages/Media.qml index 82e884c..8634522 100644 --- a/quickshell/settings/pages/Media.qml +++ b/quickshell/settings/pages/Media.qml @@ -4,27 +4,9 @@ import "../controls" import "../../components" import "../../services" import "../../media" -import "../../services/SettingsLogic.js" as Logic SettingsPage { id: root - function moduleOn(id) { - return ConfigService.data.bar.modules.some(m => m.id === id && m.enabled); - } - // Adds the module to the centre lane the first time, then just toggles it. - function setModule(id, on) { - const modules = ConfigService.data.bar.modules; - if (modules.some(m => m.id === id)) - ConfigService.setValue("bar.modules", Logic.editModule(modules, id, "enabled", on)); - else if (on) - ConfigService.setValue("bar.modules", modules.concat([ - { - id: id, - position: "center", - enabled: true - } - ])); - } SettingsSection { description: "Shared playback controls for all compatible MPRIS players." padded: true @@ -33,53 +15,6 @@ SettingsPage { Layout.fillWidth: true } } - SettingsSection { - title: "Bar" - description: "Playback and an audio visualizer in the bar. Cava shows system audio, not only the selected player, and only runs while something plays." - SettingRow { - title: "Now playing" - description: "Play/pause and the current track" - icon: "󰎈" - GlassToggle { - objectName: "mediaBarNowPlaying" - checked: root.moduleOn("nowPlaying") - onToggled: root.setModule("nowPlaying", checked) - } - } - SettingRow { - title: "Visualizer" - description: CavaService.error ? "Cava: " + CavaService.error : "Cava bars; click opens the dashboard's Media tab" - icon: "󰺢" - GlassToggle { - objectName: "mediaBarCava" - checked: root.moduleOn("cava") - onToggled: root.setModule("cava", checked) - } - } - PreferenceSlider { - label: "Visualizer bars" - icon: "󰐕" - setting: "bar.cava.bars" - from: 4 - to: 24 - step: 1 - enabled: root.moduleOn("cava") - } - PreferenceChoice { - label: "Visualizer style" - icon: "󰺢" - setting: "bar.cava.style" - choices: ["bars", "mirror"] - enabled: root.moduleOn("cava") - } - PreferenceToggle { - label: "Hide while paused" - description: "Collapse the visualizer when nothing is playing" - icon: "󰏤" - setting: "bar.cava.hideWhenIdle" - enabled: root.moduleOn("cava") - } - } SettingsSection { title: "Media cards" description: "The player in the Control Center, dashboard and this page" diff --git a/quickshell/shell.qml b/quickshell/shell.qml index 4b28ec0..4f0f667 100644 --- a/quickshell/shell.qml +++ b/quickshell/shell.qml @@ -120,6 +120,7 @@ ShellRoot { settingsOpen: ShellState.settingsOpen, settingsPage: ShellState.settingsPage, launcherOpen: ShellState.launcherOpen, + wallpaperPickerOpen: ShellState.wallpaperPickerOpen, accentSource: ConfigService.ready ? ConfigService.data.appearance.accentSource : "loading" }); } diff --git a/quickshell/testing/SettingsDriver.qml b/quickshell/testing/SettingsDriver.qml index 021acbc..ed0e456 100644 --- a/quickshell/testing/SettingsDriver.qml +++ b/quickshell/testing/SettingsDriver.qml @@ -119,7 +119,7 @@ Item { const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperCarousel"); view.positionViewAtIndex(index,ListView.Contain);input.wait(50); const item=view.itemAtIndex(index);if(!item)return false; - input.mouseClick(item,item.width/2,item.height/2);input.keyClick(Qt.Key_Return);return true; + input.mouseClick(item,item.width/2,item.height/2);return true; } function pickerScreenshot(path: string): bool {return input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperPickerSurface").grabToImage(result=>result.saveToFile(path));} function geometry(name: string): string { diff --git a/quickshell/wallpaper/WallpaperPicker.qml b/quickshell/wallpaper/WallpaperPicker.qml index 7a39b17..e757b79 100644 --- a/quickshell/wallpaper/WallpaperPicker.qml +++ b/quickshell/wallpaper/WallpaperPicker.qml @@ -103,14 +103,11 @@ PanelWindow { Rectangle {anchors.bottom:parent.bottom;anchors.left:parent.left;anchors.right:parent.right;anchors.margins:6;height:42;color:Qt.alpha(Theme.surface,0.85) Text {anchors.fill:parent;anchors.margins:10;text:(WallpaperService.currentPath===tile.modelData.path?"✓ ":"")+tile.modelData.name;color:Theme.text;elide:Text.ElideMiddle} } - MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();}onDoubleClicked:WallpaperService.apply(tile.modelData.path)} + MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}} } } Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap} - RowLayout { - Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"← → Browse · Enter or double-click to apply · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap} - GlassButton {objectName:"pickerApply";text:"Apply wallpaper";accented:true;enabled:root.results.length>0 && !WallpaperService.busy;onClicked:root.applyCurrent()} - } + Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"Click or ← → and Enter to apply · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap} } } } diff --git a/tests/launcher_runtime.py b/tests/launcher_runtime.py index 60a5fc7..4da7be6 100644 --- a/tests/launcher_runtime.py +++ b/tests/launcher_runtime.py @@ -114,13 +114,17 @@ Terminal={'true' if suffix=='Terminal' else 'false'} open_launcher();query('>') eventually(lambda:{r['id'] for r in snapshot()['results']}=={'about','appearance','audio','bar','tray','bluetooth','controlcenter','display','dock','launcher','media','metrics','network','notifications','power','wallpaper','widgets','osd','lock','dashboard','plugins'},'all commands registered') time.sleep(.3);assert ipc('launcherTest','screenshot',str(ROOT/'.cache/launcher-preview.png')) - for text,page in [('>metrics','metrics'),('>wall','wallpaper'),('>dock','dock'),('>media','media'),('>tray','tray'),('>display','displays'),('>launcher','launcher'),('>appearance','appearance'),('>bar','bar'),('>network','network'),('>bluetooth','bluetooth'),('>audio','audio'),('>controlcenter','controlcenter'),('>notifications','notifications'),('>power','power'),('>about','about')]: + for text,page in [('>metrics','metrics'),('>dock','dock'),('>media','media'),('>tray','tray'),('>display','displays'),('>launcher','launcher'),('>appearance','appearance'),('>bar','bar'),('>network','network'),('>bluetooth','bluetooth'),('>audio','audio'),('>controlcenter','controlcenter'),('>notifications','notifications'),('>power','power'),('>about','about')]: query(text) ipc('launcherTest','key',ENTER) eventually(lambda:ipc('shell','status')['settingsOpen'] and ipc('shell','status')['settingsPage']==page,'command destination '+page) assert not snapshot()['opened'] open_launcher() assert not ipc('shell','status')['settingsOpen'] + # >wallpaper opens the picker, not its settings page. + query('>wall');ipc('launcherTest','key',ENTER) + eventually(lambda:ipc('shell','status')['wallpaperPickerOpen'] and not ipc('shell','status')['settingsOpen'],'wallpaper command opens picker') + ipc('shell','close');open_launcher() query('>command-that-does-not-exist') assert not snapshot()['results'] ipc('launcherTest','key',ENTER);assert snapshot()['opened']