import QtQuick import QtQuick.Layouts import Quickshell import Quickshell.Wayland PanelWindow { id: root required property var screen required property QtObject theme required property QtObject niriService required property QtObject timeService required property QtObject resourceService required property QtObject notificationService required property QtObject trayService required property QtObject mediaService required property QtObject clipboardService required property QtObject launcherService required property QtObject audioService required property QtObject brightnessService required property QtObject networkService required property QtObject bluetoothService required property QtObject powerService required property QtObject idleService required property QtObject lockService required property QtObject surfaces required property QtObject usageService function chipLabel(name) { switch (String(name)) { case "clock": return root.timeService ? root.timeService.compact : "--:--"; case "launcher": return "launch"; case "media": return "media"; case "system": return "system"; case "clipboard": return "clip"; case "audio": return root.audioService ? root.audioService.privacyLabel().toLowerCase() : "audio"; case "brightness": return "bright"; case "connectivity": return "network"; case "power": return "power"; case "notifications": return "notify"; case "tray": return root.trayService && root.trayService.attentionCount > 0 ? `tray ${root.trayService.attentionCount}` : "tray"; case "idle": return "idle"; } return String(name); } function chipWidth(name) { switch (String(name)) { case "clock": return 70; case "launcher": return 68; case "media": return 60; case "system": return 96; case "clipboard": return 54; case "audio": return root.audioService && root.audioService.privacyLabel() === "Mic Cam" ? 80 : 62; case "brightness": return 66; case "connectivity": return 78; case "power": return 64; case "notifications": return 66; case "tray": return root.trayService && root.trayService.attentionCount > 0 ? 66 : 54; case "idle": return 50; } return 60; } // "something active inside" — drives a super subtle active dot on the chip function chipActive(name) { switch (String(name)) { case "media": return !!(root.mediaService && root.mediaService.playing); case "notifications": return !!(root.notificationService && root.notificationService.unreadCount > 0); case "tray": return !!(root.trayService && root.trayService.attentionCount > 0); case "idle": return !!(root.idleService && root.idleService.enabled); case "audio": return !!(root.audioService && root.audioService.privacyActive()); } return false; } // idle (keep-awake) is important enough to pop louder than a subtle dot function chipActiveStrong(name) { return String(name) === "idle" && root.chipActive(name); } function itemRectInBar(item) { let x = 0; let y = 0; let cursor = item; while (cursor && cursor !== root.contentItem) { x += cursor.x; y += cursor.y; cursor = cursor.parent; } return { "x": x, "y": y, "width": item.width, "height": item.height }; } function registerAnchor(name, item) { if (!root.surfaces || !item || item.width <= 0 || item.height <= 0) return ; const rect = itemRectInBar(item); root.surfaces.registerAnchor(name, `${Math.round(rect.x)},${Math.round(rect.y)},${Math.round(rect.width)},${Math.round(rect.height)}`); } function activatePopout(name) { if (!root.surfaces) return ; const target = String(name); if (root.surfaces.popoutOpen && root.surfaces.popoutName === target) { root.surfaces.closePopout("bar-toggle"); } else { if (root.usageService) root.usageService.record(target); root.surfaces.openRegisteredPopout(target); } } function refreshSurfaceGeometry() { if (root.surfaces) root.surfaces.setPopoutScreen(Math.round(root.width), Math.round(root.screen ? root.screen.height : root.height), Math.round(root.height)); } screen: root.screen implicitHeight: 34 color: "transparent" WlrLayershell.namespace: "nuguland-bar" WlrLayershell.layer: WlrLayer.Top WlrLayershell.keyboardFocus: WlrKeyboardFocus.None Component.onCompleted: Qt.callLater(root.refreshSurfaceGeometry) onSurfacesChanged: Qt.callLater(root.refreshSurfaceGeometry) onWidthChanged: root.refreshSurfaceGeometry() onHeightChanged: root.refreshSurfaceGeometry() anchors { top: true left: true right: true } Rectangle { anchors.fill: parent color: "transparent" Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom height: 1 color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.55) : "transparent" } RowLayout { anchors.fill: parent anchors.leftMargin: 10 anchors.rightMargin: 10 spacing: 10 Row { id: workspaceStrip Layout.fillWidth: true Layout.minimumWidth: 160 Layout.preferredHeight: 26 Layout.alignment: Qt.AlignVCenter spacing: 4 clip: true Repeater { // only this monitor's workspaces, idx-sorted, so each bar // reads its own 1..N instead of every output's union. model: root.niriService ? root.niriService.workspacesForOutput(root.screen ? root.screen.name : "") : [] delegate: Rectangle { id: workspaceChip required property var modelData readonly property bool active: !!modelData.is_focused readonly property string workspaceLabel: `${modelData.idx || modelData.id || "?"}${modelData.name ? ` ${modelData.name}` : ""}`.toLowerCase() width: Math.max(34, workspaceText.implicitWidth + 18) height: 26 radius: 9 color: root.theme ? (active ? root.theme.withAlpha(root.theme.ui.focus, 0.28) : root.theme.withAlpha(root.theme.ui.minor, 0.1)) : "transparent" border.width: 0 NuguText { id: workspaceText anchors.centerIn: parent theme: root.theme variant: "meta" text: workspaceChip.workspaceLabel color: !root.theme ? "transparent" : (workspaceChip.active ? root.theme.ui.accent : root.theme.ui.normal) } MouseArea { anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { if (root.niriService) root.niriService.focusWorkspace(workspaceChip.modelData.name || workspaceChip.modelData.idx || workspaceChip.modelData.id); } } } } } RowLayout { Layout.alignment: Qt.AlignVCenter spacing: 4 Repeater { model: root.usageService ? root.usageService.layoutOrder : [] delegate: BarChip { required property var modelData popoutName: modelData label: root.chipLabel(modelData) preferredWidth: root.chipWidth(modelData) } } } } } PopoutHost { theme: root.theme surfaces: root.surfaces niriService: root.niriService timeService: root.timeService resourceService: root.resourceService notificationService: root.notificationService trayService: root.trayService mediaService: root.mediaService clipboardService: root.clipboardService launcherService: root.launcherService audioService: root.audioService brightnessService: root.brightnessService networkService: root.networkService bluetoothService: root.bluetoothService powerService: root.powerService lockService: root.lockService barWindow: root } component NuguText: Text { required property QtObject theme property string variant: "body" property bool selected: false color: !theme ? "transparent" : (selected ? theme.content.backdrop : (variant === "title" ? theme.ui.important_global : (variant === "meta" ? theme.ui.normal : theme.content.normal))) font.family: variant === "mono" ? "IBM Plex Mono" : "IBM Plex Sans" font.pixelSize: variant === "title" ? 15 : (variant === "meta" ? 13 : 14) font.bold: variant === "title" elide: Text.ElideRight } component OdometerText: Item { id: odometer required property QtObject theme property string text: "--:--" property bool selected: false property int digitWidth: 10 property int digitHeight: 18 property int separatorWidth: 5 property string fontFamily: "IBM Plex Mono" property int pixelSize: 13 readonly property string source: "Nuguland Clock.qml ClockNumber.qml" readonly property string motion: "vertical-digit-roll" readonly property bool noGlow: true readonly property bool settingsBacked: false readonly property var hardSeparators: [":"] readonly property var cells: makeCells(text) function makeCells(value) { const result = []; const chars = String(value).split(""); for (let i = 0; i < chars.length; i++) { const ch = chars[i]; const digit = ch >= "0" && ch <= "9"; result.push(digit ? { "kind": "digit", "value": Number(ch) } : { "kind": "separator", "value": ch }); } return result; } function colorForCell(cell) { if (!theme) return "white"; if (odometer.selected) return theme.content.backdrop; return cell.kind === "separator" ? theme.ui.accent : theme.content.normal; } implicitWidth: row.implicitWidth implicitHeight: digitHeight clip: true Row { id: row anchors.centerIn: parent spacing: 0 Repeater { model: odometer.cells delegate: Item { id: cellRoot required property var modelData width: modelData.kind === "digit" ? odometer.digitWidth : odometer.separatorWidth height: odometer.digitHeight clip: true Column { id: digitColumn visible: cellRoot.modelData.kind === "digit" y: cellRoot.modelData.kind === "digit" ? -cellRoot.modelData.value * odometer.digitHeight : 0 Repeater { model: 10 delegate: Text { width: odometer.digitWidth height: odometer.digitHeight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: String(index) font.family: odometer.fontFamily font.pixelSize: odometer.pixelSize color: odometer.colorForCell(cellRoot.modelData) } } Behavior on y { NumberAnimation { duration: odometer.theme && odometer.theme.lowPowerMode ? 0 : 220 easing.type: Easing.OutCubic } } } Text { visible: cellRoot.modelData.kind === "separator" anchors.centerIn: parent text: String(cellRoot.modelData.value) font.family: odometer.fontFamily font.pixelSize: odometer.pixelSize color: odometer.colorForCell(cellRoot.modelData) } } } } } component StateLayer: MouseArea { id: layer property QtObject theme property bool checked: false property bool disabled: false property bool shapeMorph: true property real hoverOpacity: 0.08 property real pressOpacity: 0.14 property real disabledOpacity: 0.38 property point pressOrigin: Qt.point(width / 2, height / 2) property real rippleRadius: 0 property real endRadius: Math.sqrt(width * width + height * height) * (shapeMorph ? 1.25 : 1) property string sourceMechanic: "Nuguland StateLayer.qml ButtonBase.qml" signal activated() function stateLayerContract() { return { "clickablePrimitive": "NuguStateLayer", "source": sourceMechanic, "hoverOpacity": hoverOpacity, "pressOpacity": pressOpacity, "disabledOpacity": disabledOpacity, "rippleRadius": "radial-press-feedback", "pressOrigin": "pointer-local-origin", "shapeMorph": shapeMorph, "keyboardActivation": ["Return", "Space"], "roles": { "checked": "ui.focus", "hover": "ui.accent", "disabled": "ui.minor" } }; } function beginPress(x, y) { pressOrigin = Qt.point(x, y); rippleRadius = 0; rippleAnimation.restart(); } function keyboardActivate() { beginPress(width / 2, height / 2); activated(); } anchors.fill: parent clip: true enabled: !disabled hoverEnabled: true acceptedButtons: Qt.LeftButton cursorShape: disabled ? Qt.ArrowCursor : Qt.PointingHandCursor activeFocusOnTab: !disabled onPressed: (event) => { return beginPress(event.x, event.y); } onClicked: activated() Keys.onReturnPressed: (event) => { event.accepted = true; keyboardActivate(); } Keys.onSpacePressed: (event) => { event.accepted = true; keyboardActivate(); } Rectangle { anchors.fill: parent radius: parent && parent.parent && parent.parent.radius !== undefined ? parent.parent.radius : 0 color: layer.theme ? layer.theme.ui.accent : "white" opacity: layer.disabled ? layer.disabledOpacity : layer.pressed ? layer.pressOpacity : layer.containsMouse || layer.checked ? layer.hoverOpacity : 0 Behavior on opacity { NumberAnimation { duration: layer.theme && layer.theme.lowPowerMode ? 0 : 120 easing.type: Easing.OutCubic } } } Rectangle { width: layer.rippleRadius * 2 height: width x: layer.pressOrigin.x - width / 2 y: layer.pressOrigin.y - height / 2 radius: width / 2 color: layer.theme ? layer.theme.ui.accent : "white" opacity: layer.pressed ? layer.pressOpacity : 0 Behavior on opacity { NumberAnimation { duration: layer.theme && layer.theme.lowPowerMode ? 0 : 160 easing.type: Easing.OutCubic } } } NumberAnimation { id: rippleAnimation target: layer property: "rippleRadius" to: layer.endRadius duration: layer.theme && layer.theme.lowPowerMode ? 0 : 220 easing.type: Easing.OutCubic } } component BarChip: Rectangle { id: chip required property string popoutName required property string label property int preferredWidth: Math.max(52, labelText.implicitWidth + 18) readonly property bool selected: root.surfaces && root.surfaces.popoutName === popoutName readonly property bool active: root.chipActive(popoutName) readonly property bool activeStrong: root.chipActiveStrong(popoutName) Layout.preferredWidth: preferredWidth Layout.preferredHeight: 26 Layout.alignment: Qt.AlignVCenter radius: 9 color: !root.theme ? "transparent" : (selected ? root.theme.ui.focus : (activeStrong && !selected ? root.theme.withAlpha(root.theme.ui.accent, 0.3) : root.theme.withAlpha(root.theme.ui.minor, 0.1))) clip: true border.width: chip.activeStrong && !chip.selected ? 1 : 0 border.color: root.theme && chip.activeStrong ? root.theme.ui.accent : "transparent" Component.onCompleted: Qt.callLater(() => { return root.registerAnchor(chip.popoutName, chip); }) onXChanged: root.registerAnchor(chip.popoutName, chip) onYChanged: root.registerAnchor(chip.popoutName, chip) onWidthChanged: root.registerAnchor(chip.popoutName, chip) onHeightChanged: root.registerAnchor(chip.popoutName, chip) NuguText { id: labelText anchors.centerIn: parent width: Math.max(0, parent.width - 14) theme: root.theme variant: "meta" selected: chip.selected text: chip.label font.bold: chip.activeStrong && !chip.selected horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight color: !root.theme ? "transparent" : (chip.selected ? root.theme.content.backdrop : (chip.activeStrong ? root.theme.ui.accent : root.theme.content.normal)) z: 2 } Rectangle { id: activeDot visible: chip.active && !chip.activeStrong && !chip.selected width: 5 height: 5 radius: 2.5 anchors.top: parent.top anchors.right: parent.right anchors.topMargin: 4 anchors.rightMargin: 5 color: root.theme ? root.theme.ui.accent : "white" opacity: 0.9 z: 4 Behavior on opacity { NumberAnimation { duration: root.theme && root.theme.lowPowerMode ? 0 : 160 easing.type: Easing.OutCubic } } } StateLayer { theme: root.theme checked: chip.selected z: 3 onEntered: { // idle is a toggle, not a popout — no hover-switch if (chip.popoutName === "idle") return ; if (root.surfaces) root.surfaces.hoverRegisteredPopout(chip.popoutName); } onActivated: { if (chip.popoutName === "idle") { if (root.usageService) root.usageService.record("idle"); if (root.idleService) root.idleService.toggle(); return ; } if (root.surfaces) root.activatePopout(chip.popoutName); } } } }