From e4ca1f5d9c8cf75b02ef36e37ba61715be2354a2 Mon Sep 17 00:00:00 2001 From: mx Date: Thu, 12 Nov 2026 17:18:58 +0100 Subject: [PATCH] Add notch opacity and colour; open plugin panels from the notch strip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Settings → Notch → Look: opacity (0% glass to 100% solid) and colour for the notch, the open notch and the notch-mode launcher. - Bar popouts and plugin panels add the open notch's screen offset, so tooltips and panels from the strip land under their module. - Opening a plugin panel keeps the notch open; the notch hands keyboard focus to the panel and takes it back when it closes. Co-Authored-By: Claude Opus 5.5 --- quickshell/bar/BarPopout.qml | 5 ++- .../compat/omarchy/Ui/GlassPopupBase.qml | 5 ++- quickshell/config/defaults.json | 4 +- quickshell/core/SettingsRegistry.qml | 2 +- quickshell/launcher/Launcher.qml | 1 + quickshell/notch/Notch.qml | 16 +++++++- quickshell/notch/NotchPill.qml | 1 + quickshell/services/ApplicationsService.qml | 21 ++++++---- quickshell/services/ConfigLogic.js | 1 + quickshell/services/PluginService.qml | 7 +++- quickshell/settings/pages/Notch.qml | 41 +++++++++++++++++++ quickshell/theme/Theme.qml | 8 ++++ 12 files changed, 98 insertions(+), 14 deletions(-) diff --git a/quickshell/bar/BarPopout.qml b/quickshell/bar/BarPopout.qml index f51bf0a..dbcfe53 100644 --- a/quickshell/bar/BarPopout.qml +++ b/quickshell/bar/BarPopout.qml @@ -21,7 +21,10 @@ PanelWindow { // so the drawer stays put while the pointer moves between its entries. readonly property var anchorObject: anchorItem readonly property Item placementItem: anchorObject ? (anchorObject.placement || anchorObject) : null - readonly property point anchorPoint: placementItem && anchorWindow ? placementItem.mapToItem(anchorWindow.contentItem, 0, 0) : Qt.point(0, 0) + // Window-relative, plus the window's screen offset for centred layers (the notch). + readonly property real windowOffsetX: anchorWindow && anchorWindow.screenOffsetX !== undefined ? anchorWindow.screenOffsetX : 0 + readonly property point windowPoint: placementItem && anchorWindow ? placementItem.mapToItem(anchorWindow.contentItem, 0, 0) : Qt.point(0, 0) + readonly property point anchorPoint: Qt.point(windowPoint.x + windowOffsetX, windowPoint.y) readonly property real availableWidth: screen ? screen.width : 1280 readonly property real targetWidth: Math.ceil(root.kind === "window" ? windowCard.implicitWidth : tip.implicitWidth) readonly property real targetHeight: Math.ceil(root.kind === "window" ? windowCard.implicitHeight : tip.implicitHeight) diff --git a/quickshell/compat/omarchy/Ui/GlassPopupBase.qml b/quickshell/compat/omarchy/Ui/GlassPopupBase.qml index 09686db..7e03212 100644 --- a/quickshell/compat/omarchy/Ui/GlassPopupBase.qml +++ b/quickshell/compat/omarchy/Ui/GlassPopupBase.qml @@ -83,7 +83,10 @@ PanelWindow { readonly property point anchorScreenPos: { root.open if (!anchorItem || !anchorWindow) return Qt.point(0, 0) - return anchorItem.mapToItem(anchorWindow.contentItem, 0, 0) + const p = anchorItem.mapToItem(anchorWindow.contentItem, 0, 0) + // Centred layers (the open notch) report their screen offset. + const offset = anchorWindow.screenOffsetX !== undefined ? anchorWindow.screenOffsetX : 0 + return Qt.point(p.x + offset, p.y) } readonly property real anchorW: anchorItem ? anchorItem.width : 0 readonly property real anchorH: anchorItem ? anchorItem.height : 0 diff --git a/quickshell/config/defaults.json b/quickshell/config/defaults.json index 3ec8eeb..40e3cd4 100644 --- a/quickshell/config/defaults.json +++ b/quickshell/config/defaults.json @@ -268,7 +268,9 @@ "left": ["workspaces"], "right": ["tray"], "strip": [], - "controls": [] + "controls": [], + "opacity": 0, + "color": "" }, "dashboard": { "enabled": true, diff --git a/quickshell/core/SettingsRegistry.qml b/quickshell/core/SettingsRegistry.qml index a13974b..0762612 100644 --- a/quickshell/core/SettingsRegistry.qml +++ b/quickshell/core/SettingsRegistry.qml @@ -79,7 +79,7 @@ Singleton { available: true, group: "shell", icon: "󰹑", - keywords: ["Notch", "Notch mode", "Open on Media while audio plays", "Pocket-dots", "Left island", "Right island", "Notch strip"] + keywords: ["Notch", "Notch mode", "Notch opacity", "Notch colour", "Open on Media while audio plays", "Pocket-dots", "Left island", "Right island", "Notch strip"] }, { id: "tray", diff --git a/quickshell/launcher/Launcher.qml b/quickshell/launcher/Launcher.qml index 6cf499a..e70a629 100644 --- a/quickshell/launcher/Launcher.qml +++ b/quickshell/launcher/Launcher.qml @@ -275,6 +275,7 @@ PanelWindow { bodyHeight: panel.height ear: BarDrawers.ear radius: panel.radius + fillColor: Theme.notchFill } GlassPanel { id: panel diff --git a/quickshell/notch/Notch.qml b/quickshell/notch/Notch.qml index 283285e..c7fd59b 100644 --- a/quickshell/notch/Notch.qml +++ b/quickshell/notch/Notch.qml @@ -83,6 +83,9 @@ PanelWindow { readonly property real contentOpacity: Math.max(0, Math.min(1, (progress - 0.55) / 0.4)) anchors.top: true + // Screen x of this centred layer, so bar popouts (plugin tooltips) anchored + // in the strip land under their module. + readonly property real screenOffsetX: Math.round((screenWidth - implicitWidth) / 2) implicitWidth: Math.round(bodyWidth + 2 * ear) implicitHeight: Math.max(1, Math.round(bodyHeight)) visible: ShellState.notchOpen || progress > 0.001 @@ -91,7 +94,8 @@ PanelWindow { WlrLayershell.layer: WlrLayer.Overlay // Shares the dashboard's HyprGlass namespace (already whitelisted). WlrLayershell.namespace: "glassMxrph-dashboard" - WlrLayershell.keyboardFocus: ShellState.notchOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + // A plugin panel opened from the strip takes focus (and the pointer) while it is open. + WlrLayershell.keyboardFocus: ShellState.notchOpen && !PluginService.activePopout ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None Component.onCompleted: ShellState.notchWindow = root Component.onDestruction: ShellState.notchWindow = null @@ -107,6 +111,15 @@ PanelWindow { } } + // Keyboard focus comes back once a plugin panel from the strip closes. + Connections { + target: PluginService + function onActivePopoutChanged() { + if (!PluginService.activePopout && ShellState.notchOpen) + body.forceActiveFocus(); + } + } + // Exclusive focus routes outside clicks here (see ControlCenter). MouseArea { objectName: "notchOutside" @@ -122,6 +135,7 @@ PanelWindow { bodyHeight: root.bodyHeight ear: root.ear radius: Math.min(Theme.radius + 8, root.bodyHeight / 2) + fillColor: Theme.notchFill } Item { diff --git a/quickshell/notch/NotchPill.qml b/quickshell/notch/NotchPill.qml index e1ae4cc..6cb0216 100644 --- a/quickshell/notch/NotchPill.qml +++ b/quickshell/notch/NotchPill.qml @@ -38,6 +38,7 @@ Item { bodyHeight: root.height ear: BarDrawers.ear radius: Math.min(Theme.radius, root.height / 2) + fillColor: Theme.notchFill } Row { id: content diff --git a/quickshell/services/ApplicationsService.qml b/quickshell/services/ApplicationsService.qml index 23ec203..043e79c 100644 --- a/quickshell/services/ApplicationsService.qml +++ b/quickshell/services/ApplicationsService.qml @@ -19,21 +19,26 @@ Singleton { error = "This desktop entry is no longer installed."; return false; } + let command = action ? action.command : entry.command; if (entry.runInTerminal) { const terminal = ConfigService.data.dock.terminalCommand; if (!terminal.length) { error = "Set dock.terminalCommand to a terminal command argument array before launching terminal applications."; return false; } - Quickshell.execDetached({ - command: terminal.concat(action ? action.command : entry.command), - workingDirectory: entry.workingDirectory - }); - } else if (action) - action.execute(); - else - entry.execute(); + command = terminal.concat(command); + } + Quickshell.execDetached({ + command: scoped(command), + workingDirectory: entry.workingDirectory + }); error = ""; return true; } + // Run the app in its own transient systemd scope. Launched directly, it would + // join the shell's cgroup and be killed whenever the shell service restarts. + // Falls back to a plain launch where systemd-run is unavailable. + function scoped(command) { + return ["sh", "-c", 'if command -v systemd-run >/dev/null 2>&1; then exec systemd-run --user --scope --collect --quiet -- "$@"; fi; exec "$@"', "sh"].concat(command); + } } diff --git a/quickshell/services/ConfigLogic.js b/quickshell/services/ConfigLogic.js index a54a81d..42e7a87 100644 --- a/quickshell/services/ConfigLogic.js +++ b/quickshell/services/ConfigLogic.js @@ -87,6 +87,7 @@ function validate(c) { if(!c.notch || ["enabled","mediaFirst"].some(k=>typeof c.notch[k]!=="boolean"))throw Error("Invalid notch preferences"); for(const key of ["left","right","strip"]) if(!Array.isArray(c.notch[key]) || c.notch[key].some(id=>typeof id!=="string" || !id))throw Error("Invalid notch modules"); if(!Array.isArray(c.notch.controls) || c.notch.controls.some(m=>!m || typeof m.id!=="string" || typeof m.enabled!=="boolean" || ["w","h"].some(k=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<1 || m[k]>4)) || [["x",3],["y",63]].some(([k,max])=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<0 || m[k]>max))))throw Error("Invalid notch controls"); + if(!Number.isFinite(c.notch.opacity) || c.notch.opacity<0 || c.notch.opacity>100 || typeof c.notch.color!=="string" || (c.notch.color!=="" && !/^#[0-9a-fA-F]{6}$/.test(c.notch.color)))throw Error("Invalid notch colour"); if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences"); const notes=c.notifications; if(!notes || ["enabled","doNotDisturb","criticalInDnd"].some(k=>typeof notes[k]!=="boolean") || !["slide","drop","fade","shrink"].includes(notes.animation) || !["top-right","top-center"].includes(notes.position) || !Number.isInteger(notes.timeout) || notes.timeout<1000 || notes.timeout>30000 || !Number.isInteger(notes.maxPopups) || notes.maxPopups<1 || notes.maxPopups>6)throw Error("Invalid notification preferences"); diff --git a/quickshell/services/PluginService.qml b/quickshell/services/PluginService.qml index 7d9f9a2..e255f24 100644 --- a/quickshell/services/PluginService.qml +++ b/quickshell/services/PluginService.qml @@ -238,8 +238,9 @@ Singleton { if (activePopout && activePopout !== owner && typeof activePopout.close === "function") activePopout.close(); activePopout = owner; + // The notch stays open: its strip hosts plugin widgets whose panels + // open from it. It hands keyboard focus over while one is open. ShellState.controlCenterOpen = false; - ShellState.notchOpen = false; ShellState.dashboardOpen = false; PopoutState.close(); TrayService.close(); @@ -413,6 +414,10 @@ Singleton { if (ShellState.launcherOpen) root.closePopout(); } + function onNotchOpenChanged() { + if (!ShellState.notchOpen) + root.closePopout(); + } function onSettingsOpenChanged() { if (ShellState.settingsOpen) root.closePopout(); diff --git a/quickshell/settings/pages/Notch.qml b/quickshell/settings/pages/Notch.qml index 5c64b9e..3c3db8f 100644 --- a/quickshell/settings/pages/Notch.qml +++ b/quickshell/settings/pages/Notch.qml @@ -72,6 +72,47 @@ SettingsPage { setting: "notch.enabled" } } + SettingsSection { + title: "Look" + description: "0% is the normal glass. Raise the opacity towards a solid colour: e.g. 50% with a purple colour, or 100% black for OLED." + enabled: root.options.enabled + PreferenceSlider { + label: "Notch opacity" + icon: "󰃟" + setting: "notch.opacity" + from: 0 + to: 100 + step: 1 + unit: "%" + } + SettingRow { + title: "Notch colour" + description: root.options.color ? "Custom colour" : "Glass tint (Appearance)" + icon: "󰏘" + setting: "notch.color" + GlassTextField { + Layout.preferredWidth: 120 + color: Theme.text + selectByMouse: true + placeholderText: "Glass tint" + text: root.options.color + validator: RegularExpressionValidator { + regularExpression: /(#[0-9a-fA-F]{6})?/ + } + onEditingFinished: if (acceptableInput) + ConfigService.setValue("notch.color", text) + } + GlassButton { + text: "Black" + onClicked: ConfigService.setValue("notch.color", "#000000") + } + below: GlassColorPicker { + Layout.fillWidth: true + selectedColor: root.options.color || Theme.tint + onChosen: color => ConfigService.setValue("notch.color", color.toString()) + } + } + } SettingsSection { title: "Opening" enabled: root.options.enabled diff --git a/quickshell/theme/Theme.qml b/quickshell/theme/Theme.qml index e571ae1..c628b9a 100644 --- a/quickshell/theme/Theme.qml +++ b/quickshell/theme/Theme.qml @@ -32,6 +32,14 @@ Singleton { // opacity, controls and cards are translucent shades of it (never grey overlays). readonly property color tint: ConfigService.ready && /^#[0-9a-fA-F]{6}$/.test(ConfigService.data.appearance.glassTint) ? ConfigService.data.appearance.glassTint : "#000000" readonly property color surface: tint + // Notch mode's fill: at opacity 0 it is the normal glass; raising it moves + // towards a solid colour (the glass tint unless a notch colour is set). + readonly property color notchFill: { + const n = ConfigService.ready ? ConfigService.data.notch : null; + const c = n && /^#[0-9a-fA-F]{6}$/.test(n.color) ? n.color : tint; + const o = n ? Math.max(0, Math.min(100, n.opacity)) / 100 : 0; + return Qt.alpha(c, glassOpacity + (1 - glassOpacity) * o); + } readonly property color surfaceVariant: Qt.alpha(tint, 0.38) readonly property color fill: Qt.alpha(tint, 0.22) readonly property color hover: Qt.alpha(text, 0.09)