From e814ba58274ce27a3342b58df40cdeb4a65f5ce6 Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Thu, 13 Nov 2025 14:48:20 +0530 Subject: [PATCH 01/23] feat: Add MangoWC compositor support --- Services/Compositor/CompositorService.qml | 30 +- Services/Compositor/MangoService.qml | 627 ++++++++++++++++++++++ 2 files changed, 655 insertions(+), 2 deletions(-) create mode 100644 Services/Compositor/MangoService.qml diff --git a/Services/Compositor/CompositorService.qml b/Services/Compositor/CompositorService.qml index 0ce10ffa..11dc118d 100644 --- a/Services/Compositor/CompositorService.qml +++ b/Services/Compositor/CompositorService.qml @@ -13,6 +13,7 @@ Singleton { property bool isHyprland: false property bool isNiri: false property bool isSway: false + property bool isMango: false // Generic workspace and window data property ListModel workspaces: ListModel {} @@ -50,30 +51,47 @@ Singleton { const hyprlandSignature = Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") const niriSocket = Quickshell.env("NIRI_SOCKET") const swaySock = Quickshell.env("SWAYSOCK") - if (niriSocket && niriSocket.length > 0) { + const currentDesktop = Quickshell.env("XDG_CURRENT_DESKTOP") + + // Check for MangoWC using XDG_CURRENT_DESKTOP environment variable + // MangoWC sets XDG_CURRENT_DESKTOP=mango + if (currentDesktop && currentDesktop.toLowerCase().includes("mango")) { + isHyprland = false + isNiri = false + isSway = false + isMango = true + backendLoader.sourceComponent = mangoComponent + Logger.i("CompositorService", "MangoWC detected via XDG_CURRENT_DESKTOP:", currentDesktop) + } else if (niriSocket && niriSocket.length > 0) { isHyprland = false isNiri = true isSway = false + isMango = false backendLoader.sourceComponent = niriComponent } else if (hyprlandSignature && hyprlandSignature.length > 0) { isHyprland = true isNiri = false isSway = false + isMango = false backendLoader.sourceComponent = hyprlandComponent } else if (swaySock && swaySock.length > 0) { isHyprland = false isNiri = false isSway = true + isMango = false backendLoader.sourceComponent = swayComponent } else { // Always fallback to Niri isHyprland = false isNiri = true isSway = false + isMango = false backendLoader.sourceComponent = niriComponent } } + + Loader { id: backendLoader onLoaded: { @@ -134,6 +152,14 @@ Singleton { } } + // Mango backend component + Component { + id: mangoComponent + MangoService { + id: mangoBackend + } + } + function setupBackendConnections() { if (!backend) return @@ -161,7 +187,7 @@ Singleton { windowListChanged() }) - // Property bindings + // Property bindings - use automatic property change signal backend.focusedWindowIndexChanged.connect(() => { focusedWindowIndex = backend.focusedWindowIndex }) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml new file mode 100644 index 00000000..3c7967b4 --- /dev/null +++ b/Services/Compositor/MangoService.qml @@ -0,0 +1,627 @@ +import QtQuick +import Quickshell +import Quickshell.Io +import qs.Commons +import qs.Services.Keyboard + +Item { + id: root + + // Properties that match the facade interface + property ListModel workspaces: ListModel {} + property var windows: [] + property int focusedWindowIndex: -1 + + // Signals that match the facade interface + signal workspaceChanged + signal activeWindowChanged + signal windowListChanged + signal displayScalesChanged + + // Mango-specific properties + property bool initialized: false + property bool overviewActive: false + property var tagCache: ({}) + property var windowCache: ({}) + property var monitorCache: ({}) + property string currentLayout: "" + property string currentKeyboardLayout: "" + + // Debounce timer for updates + Timer { + id: updateTimer + interval: 50 + repeat: false + onTriggered: safeUpdate() + } + + // Initialization + function initialize() { + if (initialized) + return + + try { + // Initial data fetch + updateWorkspaces() + updateWindows() + queryDisplayScales() + queryKeyboardLayout() + + // Start event watching + mangoEventStream.running = true + + initialized = true + Logger.i("MangoService", "Service started") + } catch (e) { + Logger.e("MangoService", "Failed to initialize:", e) + } + } + + // Update workspaces (tags in MangoWC) + function updateWorkspaces() { + mangoTagsProcess.running = true + } + + // Update windows + function updateWindows() { + mangoWindowsProcess.running = true + } + + // Query display scales + function queryDisplayScales() { + mangoOutputsProcess.running = true + } + + // Query keyboard layout + function queryKeyboardLayout() { + mangoKeyboardProcess.running = true + } + + // Mango outputs process for display scale detection + Process { + id: mangoOutputsProcess + running: false + command: ["mmsg", "-g", "-A"] + + stdout: SplitParser { + onRead: function (line) { + try { + const parts = line.trim().split(/\s+/) + if (parts.length >= 3 && parts[1] === "scale_factor") { + const outputName = parts[0] + const scaleFactor = parseFloat(parts[2]) + + if (!monitorCache[outputName]) { + monitorCache[outputName] = {} + } + + monitorCache[outputName].scale = scaleFactor + monitorCache[outputName].name = outputName + } + } catch (e) { + Logger.e("MangoService", "Failed to parse output scale:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Failed to query outputs, exit code:", exitCode) + return + } + + // Convert to expected format and notify + const scales = {} + for (const [outputName, data] of Object.entries(monitorCache)) { + scales[outputName] = { + "name": data.name, + "scale": data.scale || 1.0, + "width": data.width || 0, + "height": data.height || 0, + "refresh_rate": data.refresh_rate || 0, + "x": data.x || 0, + "y": data.y || 0, + "active": data.active || false, + "focused": data.focused || false + } + } + + // Notify CompositorService + if (CompositorService && CompositorService.onDisplayScalesUpdated) { + CompositorService.onDisplayScalesUpdated(scales) + } + } + } + + // Mango tags process (workspaces) + Process { + id: mangoTagsProcess + running: false + command: ["mmsg", "-g", "-t"] + + property string accumulatedOutput: "" + + stdout: SplitParser { + onRead: function (line) { + mangoTagsProcess.accumulatedOutput += line + "\n" + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Failed to query tags, exit code:", exitCode) + accumulatedOutput = "" + return + } + + try { + parseTagsData(accumulatedOutput) + } catch (e) { + Logger.e("MangoService", "Failed to parse tags:", e) + } finally { + accumulatedOutput = "" + } + } + } + + // Mango windows process + Process { + id: mangoWindowsProcess + running: false + command: ["mmsg", "-g", "-c"] + + property string accumulatedOutput: "" + property var currentWindow: ({}) + + onRunningChanged: { + if (running) { + currentWindow = {} + } + } + + stdout: SplitParser { + onRead: function (line) { + const trimmed = line.trim() + if (!trimmed) return + + // Format: output property value + // Example: eDP-1 title joyous-triceratops | ~/.config/quickshell> y + // Example: eDP-1 appid com.mitchellh.ghostty + const firstSpace = trimmed.indexOf(' ') + if (firstSpace === -1) return + + const outputName = trimmed.substring(0, firstSpace) + const rest = trimmed.substring(firstSpace + 1).trim() + + const secondSpace = rest.indexOf(' ') + if (secondSpace === -1) return + + const property = rest.substring(0, secondSpace) + const value = rest.substring(secondSpace + 1).trim() + + + + if (!mangoWindowsProcess.currentWindow[outputName]) { + mangoWindowsProcess.currentWindow[outputName] = {} + } + + if (property === "title") { + mangoWindowsProcess.currentWindow[outputName].title = value + } else if (property === "appid") { + mangoWindowsProcess.currentWindow[outputName].appId = value + } else if (property === "fullscreen") { + mangoWindowsProcess.currentWindow[outputName].isFullscreen = value === "1" + } else if (property === "floating") { + mangoWindowsProcess.currentWindow[outputName].isFloating = value === "1" + } else if (property === "x") { + mangoWindowsProcess.currentWindow[outputName].x = parseInt(value) + } else if (property === "y") { + mangoWindowsProcess.currentWindow[outputName].y = parseInt(value) + } else if (property === "width") { + mangoWindowsProcess.currentWindow[outputName].width = parseInt(value) + } else if (property === "height") { + mangoWindowsProcess.currentWindow[outputName].height = parseInt(value) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Failed to query windows, exit code:", exitCode) + accumulatedOutput = "" + currentWindow = {} + return + } + + try { + parseWindowsData(currentWindow) + } catch (e) { + Logger.e("MangoService", "Failed to parse windows:", e) + } finally { + currentWindow = {} + } + } + } + + // Mango keyboard layout process + Process { + id: mangoKeyboardProcess + running: false + command: ["mmsg", "-g", "-k"] + + stdout: SplitParser { + onRead: function (line) { + try { + const parts = line.trim().split(/\s+/) + if (parts.length >= 2 && parts[1] === "kb_layout") { + const layoutName = parts.slice(2).join(' ') + if (layoutName && layoutName !== currentKeyboardLayout) { + currentKeyboardLayout = layoutName + KeyboardLayoutService.setCurrentLayout(layoutName) + + } + } + } catch (e) { + Logger.e("MangoService", "Failed to parse keyboard layout:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Failed to query keyboard layout, exit code:", exitCode) + } + } + } + + + + // Mango event stream process + Process { + id: mangoEventStream + running: false + command: ["mmsg", "-w"] + + stdout: SplitParser { + onRead: function (line) { + try { + handleEvent(line.trim()) + } catch (e) { + Logger.e("MangoService", "Error parsing event:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Event stream exited, exit code:", exitCode) + // Restart event stream after a delay + restartTimer.start() + } + } + } + + // Timer to restart event stream + Timer { + id: restartTimer + interval: 1000 + onTriggered: { + if (initialized) { + mangoEventStream.running = true + } + } + } + + // Parse tags data and convert to workspace format + function parseTagsData(output) { + const lines = output.trim().split('\n') + const workspacesList = [] + const outputTags = {} + tagCache = {} + + for (const line of lines) { + const trimmed = line.trim() + if (!trimmed) continue + + // Parse tag information + // Format: output tag + // Example: eDP-1 tag 1 1 2 1 + const tagMatch = trimmed.match(/^(\S+)\s+tag\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) + if (tagMatch) { + const [, outputName, tagNum, state, clients, focused] = tagMatch + const tagId = parseInt(tagNum) + + // Store tag info per output + if (!outputTags[outputName]) { + outputTags[outputName] = [] + } + + // Convert MangoWC tag state to workspace properties + // Based on dwl-ipc protocol: bit 0=active, bit 1=urgent, bit 2=occupied + const isActive = (parseInt(state) & 1) !== 0 + const isUrgent = (parseInt(state) & 2) !== 0 // Note: might be bit 1 for urgent + const isOccupied = parseInt(clients) > 0 + + const workspaceData = { + "id": tagId, + "idx": tagId, + "name": tagId.toString(), + "output": outputName, + "isActive": isActive, + "isFocused": isActive && parseInt(focused) === 1, + "isUrgent": isUrgent, + "isOccupied": isOccupied + } + + tagCache[tagId] = workspaceData + outputTags[outputName].push(workspaceData) + + } + + // Parse layout information + // Format: output layout + const layoutMatch = trimmed.match(/^(\S+)\s+layout\s+(\S+)$/) + if (layoutMatch) { + const [, outputName, layoutName] = layoutMatch + currentLayout = layoutName + + // Detect overview state - MangoWC uses "󰃇" symbol for overview + const wasOverviewActive = overviewActive + overviewActive = (layoutName === "󰃇") + + // Emit signal if overview state changed + if (wasOverviewActive !== overviewActive) { + Logger.d("MangoService", `Overview state changed: ${overviewActive}`) + } + } + + // Parse clients count information + // Format: output clients + const clientsMatch = trimmed.match(/^(\S+)\s+clients\s+(\d+)$/) + if (clientsMatch) { + const [, outputName, clientsCount] = clientsMatch + // Store clients count for the output + if (!monitorCache[outputName]) { + monitorCache[outputName] = {} + } + monitorCache[outputName].clientsCount = parseInt(clientsCount) + } + + // Parse tags mask information + // Format: output tags + const tagsMaskMatch = trimmed.match(/^(\S+)\s+tags\s+(\d+)\s+(\d+)\s+(\d+)$/) + if (tagsMaskMatch) { + const [, outputName, occupiedMask, selectedMask, urgentMask] = tagsMaskMatch + if (!monitorCache[outputName]) { + monitorCache[outputName] = {} + } + monitorCache[outputName].occupiedMask = parseInt(occupiedMask) + monitorCache[outputName].selectedMask = parseInt(selectedMask) + monitorCache[outputName].urgentMask = parseInt(urgentMask) + } + } + + // Flatten all tags from all outputs into a single list + for (const [outputName, tags] of Object.entries(outputTags)) { + for (const tag of tags) { + workspacesList.push(tag) + } + } + + // Sort workspaces by tag ID, then by output name + workspacesList.sort((a, b) => { + if (a.id !== b.id) { + return a.id - b.id + } + return a.output.localeCompare(b.output) + }) + + // Update workspaces ListModel + workspaces.clear() + for (var i = 0; i < workspacesList.length; i++) { + workspaces.append(workspacesList[i]) + } + + workspaceChanged() + } + + // Parse windows data + function parseWindowsData(windowData) { + + const windowsList = [] + windowCache = {} + let newFocusedIndex = -1 + + for (const [outputName, data] of Object.entries(windowData)) { + if (data.title || data.appId) { + const windowInfo = { + "id": outputName, // Use output name as unique identifier for now + "title": data.title || "", + "appId": data.appId || "", + "workspaceId": getCurrentTagId(), // Get current active tag + "isFocused": false, // Will be determined by focused window detection + "output": outputName, + "class": data.appId || "", + "fullscreen": data.isFullscreen || false, + "floating": data.isFloating || false, + "x": data.x || 0, + "y": data.y || 0, + "width": data.width || 0, + "height": data.height || 0 + } + + windowsList.push(windowInfo) + windowCache[outputName] = windowInfo + } + } + + // Try to determine focused window by checking which output is focused + // This is a heuristic approach since mmsg doesn't provide direct focus info + for (let i = 0; i < windowsList.length; i++) { + const window = windowsList[i] + const outputData = monitorCache[window.output] + if (outputData && outputData.focused) { + window.isFocused = true + newFocusedIndex = i + break + } + } + + // Fallback: assume first window is focused if no output focus info + if (newFocusedIndex === -1 && windowsList.length > 0) { + windowsList[0].isFocused = true + newFocusedIndex = 0 + } + + windows = windowsList + + if (newFocusedIndex !== focusedWindowIndex) { + focusedWindowIndex = newFocusedIndex + activeWindowChanged() + } + + windowListChanged() + } + + // Get current active tag ID + function getCurrentTagId() { + for (const [tagId, tagData] of Object.entries(tagCache)) { + if (tagData.isActive) { + return parseInt(tagId) + } + } + return 1 // Default to tag 1 + } + + // Handle events from mmsg -w + function handleEvent(eventLine) { + const parts = eventLine.trim().split(/\s+/) + if (parts.length < 2) return + + const outputName = parts[0] + const eventType = parts[1] + + // Handle different event types + switch (eventType) { + case "tag": + // Tag state changed + updateTimer.restart() + break + case "title": + case "appid": + case "fullscreen": + case "floating": + // Window properties changed + updateTimer.restart() + break + case "layout": + // Layout changed + updateTimer.restart() + break + case "kb_layout": + // Keyboard layout changed + const layoutName = parts.slice(2).join(' ') + if (layoutName && layoutName !== currentKeyboardLayout) { + currentKeyboardLayout = layoutName + KeyboardLayoutService.setCurrentLayout(layoutName) + } + break + case "scale_factor": + // Display scale changed + queryDisplayScales() + break + case "monitor": + // Monitor configuration changed + queryDisplayScales() + updateTimer.restart() + break + case "client": + // Client (window) focus or state changed + updateTimer.restart() + break + case "selmon": + // Selected monitor changed + updateTimer.restart() + break + default: + // Unknown event type, trigger general update + + updateTimer.restart() + break + } + } + + // Safe update wrapper + function safeUpdate() { + safeUpdateWindows() + safeUpdateWorkspaces() + windowListChanged() + } + + // Safe workspace update + function safeUpdateWorkspaces() { + try { + updateWorkspaces() + } catch (e) { + Logger.e("MangoService", "Error updating workspaces:", e) + } + } + + // Safe window update + function safeUpdateWindows() { + try { + updateWindows() + } catch (e) { + Logger.e("MangoService", "Error updating windows:", e) + } + } + + // Public functions + function switchToWorkspace(workspace) { + try { + // MangoWC uses tags 1-9, so switch to tag by ID + const tagId = workspace.idx || workspace.id || 1 + Quickshell.execDetached(["mmsg", "-d", "view", tagId.toString()]) + } catch (e) { + Logger.e("MangoService", "Failed to switch workspace:", e) + } + } + + function focusWindow(window) { + try { + // For MangoWC, we can try to focus windows by switching to their workspace + // and then using focus commands, or by cycling through windows + if (window && window.workspaceId) { + // First switch to the window's workspace/tag + Quickshell.execDetached(["mmsg", "-d", "view", window.workspaceId.toString()]) + + // Then try to focus the window by cycling or using window-specific commands + // This is a limitation of the mmsg interface - we can't directly focus by window ID + Qt.callLater(() => { + // Give the workspace switch a moment to complete, then try to find the window + // For now, we'll use a generic focus command that focuses the main window + Quickshell.execDetached(["mmsg", "-d", "focusmaster"]) + }) + } + } catch (e) { + Logger.e("MangoService", "Failed to focus window:", e) + } + } + + function closeWindow(window) { + try { + // Close focused window + Quickshell.execDetached(["mmsg", "-d", "killclient"]) + } catch (e) { + Logger.e("MangoService", "Failed to close window:", e) + } + } + + function logout() { + try { + Quickshell.execDetached(["mmsg", "-d", "quit"]) + } catch (e) { + Logger.e("MangoService", "Failed to logout:", e) + } + } +} \ No newline at end of file From 8ba0a0a51f9bd8b3f7da6988bbe8eafb3e70780e Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Thu, 13 Nov 2025 20:27:40 +0530 Subject: [PATCH 02/23] refactor: Improve MangoWC implementation --- Services/Compositor/MangoService.qml | 861 +++++++++++++-------------- 1 file changed, 410 insertions(+), 451 deletions(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index 3c7967b4..b7c9c1c7 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -2,17 +2,17 @@ import QtQuick import Quickshell import Quickshell.Io import qs.Commons -import qs.Services.Keyboard +import qs.Services.UI Item { id: root - // Properties that match the facade interface + // Properties matching facade interface property ListModel workspaces: ListModel {} property var windows: [] property int focusedWindowIndex: -1 - // Signals that match the facade interface + // Signals matching facade interface signal workspaceChanged signal activeWindowChanged signal windowListChanged @@ -21,12 +21,36 @@ Item { // Mango-specific properties property bool initialized: false property bool overviewActive: false - property var tagCache: ({}) + property var workspaceCache: ({}) property var windowCache: ({}) property var monitorCache: ({}) property string currentLayout: "" + property string currentLayoutSymbol: "" property string currentKeyboardLayout: "" + // Constants + readonly property var mmsgCommands: ({ + query: { + workspaces: ["mmsg", "-g", "-t"], + windows: ["mmsg", "-g", "-c"], + layout: ["mmsg", "-g", "-l"], + keyboard: ["mmsg", "-g", "-k"], + outputs: ["mmsg", "-g", "-A"], + eventStream: ["mmsg", "-w"] + }, + action: { + view: ["mmsg", "-d", "view"], + focusMaster: ["mmsg", "-d", "focusmaster"], + killClient: ["mmsg", "-d", "killclient"], + toggleOverview: ["mmsg", "-d", "toggleoverview"], + setLayout: ["mmsg", "-d", "setlayout"], + quit: ["mmsg", "-d", "quit"] + } + }) + + readonly property string overviewLayoutSymbol: "󰃇" + readonly property int defaultWorkspaceId: 1 + // Debounce timer for updates Timer { id: updateTimer @@ -35,53 +59,195 @@ Item { onTriggered: safeUpdate() } - // Initialization - function initialize() { - if (initialized) - return + // Event stream for real-time updates + Process { + id: eventStream + running: false + command: mmsgCommands.query.eventStream - try { - // Initial data fetch - updateWorkspaces() - updateWindows() - queryDisplayScales() - queryKeyboardLayout() - - // Start event watching - mangoEventStream.running = true - - initialized = true - Logger.i("MangoService", "Service started") - } catch (e) { - Logger.e("MangoService", "Failed to initialize:", e) + stdout: SplitParser { + onRead: function (line) { + try { + handleEvent(line.trim()) + } catch (e) { + Logger.e("MangoService", "Event parsing error:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Event stream exited, restarting...") + restartTimer.start() + } } } - // Update workspaces (tags in MangoWC) - function updateWorkspaces() { - mangoTagsProcess.running = true + Timer { + id: restartTimer + interval: 1000 + onTriggered: { + if (initialized) { + eventStream.running = true + } + } } - // Update windows - function updateWindows() { - mangoWindowsProcess.running = true - } - - // Query display scales - function queryDisplayScales() { - mangoOutputsProcess.running = true - } - - // Query keyboard layout - function queryKeyboardLayout() { - mangoKeyboardProcess.running = true - } - - // Mango outputs process for display scale detection + // Query processes Process { - id: mangoOutputsProcess + id: workspacesProcess running: false - command: ["mmsg", "-g", "-A"] + command: mmsgCommands.query.workspaces + property string accumulatedOutput: "" + + stdout: SplitParser { + onRead: function (line) { + workspacesProcess.accumulatedOutput += line + "\n" + } + } + + onExited: function (exitCode) { + if (exitCode === 0) { + parseWorkspaces(accumulatedOutput) + } else { + Logger.e("MangoService", "Workspaces query failed:", exitCode) + } + accumulatedOutput = "" + } + } + + Process { + id: windowsProcess + running: false + command: mmsgCommands.query.windows + property string accumulatedOutput: "" + property var currentWindow: ({}) + + onRunningChanged: { + if (running) { + currentWindow = {} + } + } + + stdout: SplitParser { + onRead: function (line) { + const trimmed = line.trim() + if (!trimmed) return + + const parts = trimmed.split(' ') + if (parts.length >= 3) { + const outputName = parts[0] + const property = parts[1] + const value = parts.slice(2).join(' ') + + if (!currentWindow[outputName]) { + currentWindow[outputName] = { + id: outputName, + output: outputName + } + } + + switch (property) { + case "title": + currentWindow[outputName].title = value + break + case "appid": + currentWindow[outputName].appId = value + currentWindow[outputName].class = value + break + case "fullscreen": + currentWindow[outputName].fullscreen = (value === "1") + break + case "floating": + currentWindow[outputName].floating = (value === "1") + break + case "x": + currentWindow[outputName].x = parseInt(value) + break + case "y": + currentWindow[outputName].y = parseInt(value) + break + case "width": + currentWindow[outputName].width = parseInt(value) + break + case "height": + currentWindow[outputName].height = parseInt(value) + break + } + } + } + } + + onExited: function (exitCode) { + if (exitCode === 0) { + parseWindows(currentWindow) + } else { + Logger.e("MangoService", "Windows query failed:", exitCode) + } + accumulatedOutput = "" + currentWindow = {} + } + } + + Process { + id: layoutProcess + running: false + command: mmsgCommands.query.layout + + stdout: SplitParser { + onRead: function (line) { + try { + const parts = line.trim().split(/\s+/) + if (parts.length >= 2) { + const layoutSymbol = parts.slice(1).join(' ') + handleLayoutChange(layoutSymbol) + } + } catch (e) { + Logger.e("MangoService", "Layout parsing error:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Layout query failed:", exitCode) + } + } + } + + Process { + id: keyboardProcess + running: false + command: mmsgCommands.query.keyboard + + stdout: SplitParser { + onRead: function (line) { + try { + const parts = line.trim().split(/\s+/) + if (parts.length >= 2 && parts[1] === "kb_layout") { + const layoutName = parts.slice(2).join(' ') + if (layoutName && layoutName !== currentKeyboardLayout) { + currentKeyboardLayout = layoutName + KeyboardLayoutService.setCurrentLayout(layoutName) + } + } + } catch (e) { + Logger.e("MangoService", "Keyboard layout parsing error:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Keyboard query failed:", exitCode) + } + } + } + + Process { + id: outputsProcess + running: false + command: mmsgCommands.query.outputs stdout: SplitParser { onRead: function (line) { @@ -99,364 +265,201 @@ Item { monitorCache[outputName].name = outputName } } catch (e) { - Logger.e("MangoService", "Failed to parse output scale:", e, line) + Logger.e("MangoService", "Output parsing error:", e, line) } } } onExited: function (exitCode) { - if (exitCode !== 0) { - Logger.e("MangoService", "Failed to query outputs, exit code:", exitCode) - return - } - - // Convert to expected format and notify - const scales = {} - for (const [outputName, data] of Object.entries(monitorCache)) { - scales[outputName] = { - "name": data.name, - "scale": data.scale || 1.0, - "width": data.width || 0, - "height": data.height || 0, - "refresh_rate": data.refresh_rate || 0, - "x": data.x || 0, - "y": data.y || 0, - "active": data.active || false, - "focused": data.focused || false - } - } - - // Notify CompositorService - if (CompositorService && CompositorService.onDisplayScalesUpdated) { - CompositorService.onDisplayScalesUpdated(scales) + if (exitCode === 0) { + updateDisplayScales() + } else { + Logger.e("MangoService", "Outputs query failed:", exitCode) } } } - // Mango tags process (workspaces) - Process { - id: mangoTagsProcess - running: false - command: ["mmsg", "-g", "-t"] - - property string accumulatedOutput: "" - - stdout: SplitParser { - onRead: function (line) { - mangoTagsProcess.accumulatedOutput += line + "\n" - } + // Initialization + function initialize() { + if (initialized) { + Logger.w("MangoService", "Already initialized") + return } - onExited: function (exitCode) { - if (exitCode !== 0) { - Logger.e("MangoService", "Failed to query tags, exit code:", exitCode) - accumulatedOutput = "" - return - } - - try { - parseTagsData(accumulatedOutput) - } catch (e) { - Logger.e("MangoService", "Failed to parse tags:", e) - } finally { - accumulatedOutput = "" - } + try { + Logger.i("MangoService", "Initializing MangoWC service...") + + eventStream.running = true + queryWorkspaces() + queryWindows() + queryLayout() + queryKeyboard() + queryOutputs() + + initialized = true + Logger.i("MangoService", "Service initialized successfully") + } catch (e) { + Logger.e("MangoService", "Initialization failed:", e) + eventStream.running = true } } - // Mango windows process - Process { - id: mangoWindowsProcess - running: false - command: ["mmsg", "-g", "-c"] - - property string accumulatedOutput: "" - property var currentWindow: ({}) - - onRunningChanged: { - if (running) { - currentWindow = {} - } + // Workspace operations + function switchToWorkspace(workspace) { + try { + const tagId = workspace.idx || workspace.id || defaultWorkspaceId + const command = mmsgCommands.action.view.concat([tagId.toString()]) + Quickshell.execDetached(command) + Logger.d("MangoService", `Switching to workspace ${tagId}`) + } catch (e) { + Logger.e("MangoService", "Failed to switch workspace:", e) } + } - stdout: SplitParser { - onRead: function (line) { - const trimmed = line.trim() - if (!trimmed) return - - // Format: output property value - // Example: eDP-1 title joyous-triceratops | ~/.config/quickshell> y - // Example: eDP-1 appid com.mitchellh.ghostty - const firstSpace = trimmed.indexOf(' ') - if (firstSpace === -1) return + // Window operations + function focusWindow(window) { + try { + if (window && window.workspaceId) { + const command = mmsgCommands.action.view.concat([window.workspaceId.toString()]) + Quickshell.execDetached(command) - const outputName = trimmed.substring(0, firstSpace) - const rest = trimmed.substring(firstSpace + 1).trim() - - const secondSpace = rest.indexOf(' ') - if (secondSpace === -1) return - - const property = rest.substring(0, secondSpace) - const value = rest.substring(secondSpace + 1).trim() - - - - if (!mangoWindowsProcess.currentWindow[outputName]) { - mangoWindowsProcess.currentWindow[outputName] = {} - } - - if (property === "title") { - mangoWindowsProcess.currentWindow[outputName].title = value - } else if (property === "appid") { - mangoWindowsProcess.currentWindow[outputName].appId = value - } else if (property === "fullscreen") { - mangoWindowsProcess.currentWindow[outputName].isFullscreen = value === "1" - } else if (property === "floating") { - mangoWindowsProcess.currentWindow[outputName].isFloating = value === "1" - } else if (property === "x") { - mangoWindowsProcess.currentWindow[outputName].x = parseInt(value) - } else if (property === "y") { - mangoWindowsProcess.currentWindow[outputName].y = parseInt(value) - } else if (property === "width") { - mangoWindowsProcess.currentWindow[outputName].width = parseInt(value) - } else if (property === "height") { - mangoWindowsProcess.currentWindow[outputName].height = parseInt(value) - } - } - } - - onExited: function (exitCode) { - if (exitCode !== 0) { - Logger.e("MangoService", "Failed to query windows, exit code:", exitCode) - accumulatedOutput = "" - currentWindow = {} - return - } - - try { - parseWindowsData(currentWindow) - } catch (e) { - Logger.e("MangoService", "Failed to parse windows:", e) - } finally { - currentWindow = {} + Qt.callLater(() => { + Quickshell.execDetached(mmsgCommands.action.focusMaster) + }) } + } catch (e) { + Logger.e("MangoService", "Failed to focus window:", e) } } - // Mango keyboard layout process - Process { - id: mangoKeyboardProcess - running: false - command: ["mmsg", "-g", "-k"] - - stdout: SplitParser { - onRead: function (line) { - try { - const parts = line.trim().split(/\s+/) - if (parts.length >= 2 && parts[1] === "kb_layout") { - const layoutName = parts.slice(2).join(' ') - if (layoutName && layoutName !== currentKeyboardLayout) { - currentKeyboardLayout = layoutName - KeyboardLayoutService.setCurrentLayout(layoutName) - - } - } - } catch (e) { - Logger.e("MangoService", "Failed to parse keyboard layout:", e, line) - } - } - } - - onExited: function (exitCode) { - if (exitCode !== 0) { - Logger.e("MangoService", "Failed to query keyboard layout, exit code:", exitCode) - } + function closeWindow() { + try { + Quickshell.execDetached(mmsgCommands.action.killClient) + } catch (e) { + Logger.e("MangoService", "Failed to close window:", e) } } - - - // Mango event stream process - Process { - id: mangoEventStream - running: false - command: ["mmsg", "-w"] - - stdout: SplitParser { - onRead: function (line) { - try { - handleEvent(line.trim()) - } catch (e) { - Logger.e("MangoService", "Error parsing event:", e, line) - } - } - } - - onExited: function (exitCode) { - if (exitCode !== 0) { - Logger.e("MangoService", "Event stream exited, exit code:", exitCode) - // Restart event stream after a delay - restartTimer.start() - } + // MangoWC-specific operations + function toggleOverview() { + try { + Quickshell.execDetached(mmsgCommands.action.toggleOverview) + } catch (e) { + Logger.e("MangoService", "Failed to toggle overview:", e) } } - // Timer to restart event stream - Timer { - id: restartTimer - interval: 1000 - onTriggered: { - if (initialized) { - mangoEventStream.running = true - } + function setLayout(layoutName) { + try { + const command = mmsgCommands.action.setLayout.concat([layoutName]) + Quickshell.execDetached(command) + } catch (e) { + Logger.e("MangoService", "Failed to set layout:", e) } } - // Parse tags data and convert to workspace format - function parseTagsData(output) { + function logout() { + try { + Quickshell.execDetached(mmsgCommands.action.quit) + } catch (e) { + Logger.e("MangoService", "Failed to logout:", e) + } + } + + // Data parsing + function parseWorkspaces(output) { const lines = output.trim().split('\n') const workspacesList = [] - const outputTags = {} - tagCache = {} + const newWorkspaceCache = {} for (const line of lines) { const trimmed = line.trim() if (!trimmed) continue - // Parse tag information - // Format: output tag - // Example: eDP-1 tag 1 1 2 1 - const tagMatch = trimmed.match(/^(\S+)\s+tag\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) - if (tagMatch) { - const [, outputName, tagNum, state, clients, focused] = tagMatch + const match = trimmed.match(/^(\S+)\s+tag\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) + if (match) { + const [, outputName, tagNum, state, clients, focused] = match const tagId = parseInt(tagNum) - // Store tag info per output - if (!outputTags[outputName]) { - outputTags[outputName] = [] - } - - // Convert MangoWC tag state to workspace properties - // Based on dwl-ipc protocol: bit 0=active, bit 1=urgent, bit 2=occupied const isActive = (parseInt(state) & 1) !== 0 - const isUrgent = (parseInt(state) & 2) !== 0 // Note: might be bit 1 for urgent + const isUrgent = (parseInt(state) & 2) !== 0 const isOccupied = parseInt(clients) > 0 + const isFocused = isActive && parseInt(focused) === 1 const workspaceData = { - "id": tagId, - "idx": tagId, - "name": tagId.toString(), - "output": outputName, - "isActive": isActive, - "isFocused": isActive && parseInt(focused) === 1, - "isUrgent": isUrgent, - "isOccupied": isOccupied + id: tagId, + idx: tagId, + name: tagId.toString(), + output: outputName, + isActive: isActive, + isFocused: isFocused, + isUrgent: isUrgent, + isOccupied: isOccupied, + clients: parseInt(clients) } - tagCache[tagId] = workspaceData - outputTags[outputName].push(workspaceData) - + newWorkspaceCache[tagId] = workspaceData + workspacesList.push(workspaceData) } - // Parse layout information - // Format: output layout const layoutMatch = trimmed.match(/^(\S+)\s+layout\s+(\S+)$/) if (layoutMatch) { - const [, outputName, layoutName] = layoutMatch - currentLayout = layoutName - - // Detect overview state - MangoWC uses "󰃇" symbol for overview - const wasOverviewActive = overviewActive - overviewActive = (layoutName === "󰃇") - - // Emit signal if overview state changed - if (wasOverviewActive !== overviewActive) { - Logger.d("MangoService", `Overview state changed: ${overviewActive}`) - } - } - - // Parse clients count information - // Format: output clients - const clientsMatch = trimmed.match(/^(\S+)\s+clients\s+(\d+)$/) - if (clientsMatch) { - const [, outputName, clientsCount] = clientsMatch - // Store clients count for the output - if (!monitorCache[outputName]) { - monitorCache[outputName] = {} - } - monitorCache[outputName].clientsCount = parseInt(clientsCount) - } - - // Parse tags mask information - // Format: output tags - const tagsMaskMatch = trimmed.match(/^(\S+)\s+tags\s+(\d+)\s+(\d+)\s+(\d+)$/) - if (tagsMaskMatch) { - const [, outputName, occupiedMask, selectedMask, urgentMask] = tagsMaskMatch - if (!monitorCache[outputName]) { - monitorCache[outputName] = {} - } - monitorCache[outputName].occupiedMask = parseInt(occupiedMask) - monitorCache[outputName].selectedMask = parseInt(selectedMask) - monitorCache[outputName].urgentMask = parseInt(urgentMask) + const [, , layoutSymbol] = layoutMatch + handleLayoutChange(layoutSymbol) } } - // Flatten all tags from all outputs into a single list - for (const [outputName, tags] of Object.entries(outputTags)) { - for (const tag of tags) { - workspacesList.push(tag) + if (JSON.stringify(newWorkspaceCache) !== JSON.stringify(workspaceCache)) { + workspaceCache = newWorkspaceCache + + workspacesList.sort((a, b) => { + if (a.id !== b.id) return a.id - b.id + return a.output.localeCompare(b.output) + }) + + workspaces.clear() + for (var i = 0; i < workspacesList.length; i++) { + workspaces.append(workspacesList[i]) } + + workspaceChanged() } - - // Sort workspaces by tag ID, then by output name - workspacesList.sort((a, b) => { - if (a.id !== b.id) { - return a.id - b.id - } - return a.output.localeCompare(b.output) - }) - - // Update workspaces ListModel - workspaces.clear() - for (var i = 0; i < workspacesList.length; i++) { - workspaces.append(workspacesList[i]) - } - - workspaceChanged() } - // Parse windows data - function parseWindowsData(windowData) { - + function parseWindows(windowData) { const windowsList = [] - windowCache = {} + const newWindowCache = {} let newFocusedIndex = -1 for (const [outputName, data] of Object.entries(windowData)) { if (data.title || data.appId) { const windowInfo = { - "id": outputName, // Use output name as unique identifier for now - "title": data.title || "", - "appId": data.appId || "", - "workspaceId": getCurrentTagId(), // Get current active tag - "isFocused": false, // Will be determined by focused window detection - "output": outputName, - "class": data.appId || "", - "fullscreen": data.isFullscreen || false, - "floating": data.isFloating || false, - "x": data.x || 0, - "y": data.y || 0, - "width": data.width || 0, - "height": data.height || 0 + id: outputName, + title: data.title || "", + appId: data.appId || "", + class: data.appId || "", + workspaceId: getCurrentActiveTagId(), + isFocused: false, + output: outputName, + fullscreen: data.fullscreen || false, + floating: data.floating || false, + x: data.x || 0, + y: data.y || 0, + width: data.width || 0, + height: data.height || 0, + geometry: { + x: data.x || 0, + y: data.y || 0, + width: data.width || 0, + height: data.height || 0 + } } windowsList.push(windowInfo) - windowCache[outputName] = windowInfo + newWindowCache[outputName] = windowInfo } } - // Try to determine focused window by checking which output is focused - // This is a heuristic approach since mmsg doesn't provide direct focus info for (let i = 0; i < windowsList.length; i++) { const window = windowsList[i] const outputData = monitorCache[window.output] @@ -467,161 +470,117 @@ Item { } } - // Fallback: assume first window is focused if no output focus info - if (newFocusedIndex === -1 && windowsList.length > 0) { - windowsList[0].isFocused = true - newFocusedIndex = 0 + if (JSON.stringify(newWindowCache) !== JSON.stringify(windowCache)) { + windowCache = newWindowCache + windows = windowsList + + if (newFocusedIndex !== focusedWindowIndex) { + focusedWindowIndex = newFocusedIndex + activeWindowChanged() + } + + windowListChanged() } - - windows = windowsList - - if (newFocusedIndex !== focusedWindowIndex) { - focusedWindowIndex = newFocusedIndex - activeWindowChanged() - } - - windowListChanged() } - // Get current active tag ID - function getCurrentTagId() { - for (const [tagId, tagData] of Object.entries(tagCache)) { - if (tagData.isActive) { - return parseInt(tagId) + function handleLayoutChange(layoutSymbol) { + const wasOverview = overviewActive + const isOverview = (layoutSymbol === overviewLayoutSymbol) + + if (wasOverview !== isOverview) { + overviewActive = isOverview + Logger.d("MangoService", `Overview mode: ${overviewActive}`) + } + + if (layoutSymbol !== currentLayoutSymbol) { + currentLayoutSymbol = layoutSymbol + currentLayout = layoutSymbol + } + } + + function updateDisplayScales() { + const scales = {} + for (const [outputName, data] of Object.entries(monitorCache)) { + scales[outputName] = { + name: data.name || outputName, + scale: data.scale || 1.0, + width: data.width || 0, + height: data.height || 0, + refresh_rate: data.refresh_rate || 0, + x: data.x || 0, + y: data.y || 0, + active: data.active || false, + focused: data.focused || false } } - return 1 // Default to tag 1 + + if (CompositorService && CompositorService.onDisplayScalesUpdated) { + CompositorService.onDisplayScalesUpdated(scales) + } + displayScalesChanged() } - // Handle events from mmsg -w + // Event handling function handleEvent(eventLine) { const parts = eventLine.trim().split(/\s+/) if (parts.length < 2) return - const outputName = parts[0] const eventType = parts[1] - // Handle different event types switch (eventType) { case "tag": - // Tag state changed - updateTimer.restart() - break case "title": case "appid": case "fullscreen": case "floating": - // Window properties changed - updateTimer.restart() - break case "layout": - // Layout changed - updateTimer.restart() - break case "kb_layout": - // Keyboard layout changed - const layoutName = parts.slice(2).join(' ') - if (layoutName && layoutName !== currentKeyboardLayout) { - currentKeyboardLayout = layoutName - KeyboardLayoutService.setCurrentLayout(layoutName) - } - break case "scale_factor": - // Display scale changed - queryDisplayScales() - break case "monitor": - // Monitor configuration changed - queryDisplayScales() - updateTimer.restart() - break case "client": - // Client (window) focus or state changed - updateTimer.restart() - break case "selmon": - // Selected monitor changed - updateTimer.restart() - break - default: - // Unknown event type, trigger general update - updateTimer.restart() break } } - // Safe update wrapper + // Queries + function queryWorkspaces() { + workspacesProcess.running = true + } + + function queryWindows() { + windowsProcess.running = true + } + + function queryLayout() { + layoutProcess.running = true + } + + function queryKeyboard() { + keyboardProcess.running = true + } + + function queryOutputs() { + outputsProcess.running = true + } + + // Utilities function safeUpdate() { - safeUpdateWindows() - safeUpdateWorkspaces() - windowListChanged() - } - - // Safe workspace update - function safeUpdateWorkspaces() { try { - updateWorkspaces() + queryWorkspaces() + queryWindows() } catch (e) { - Logger.e("MangoService", "Error updating workspaces:", e) + Logger.e("MangoService", "Safe update failed:", e) } } - // Safe window update - function safeUpdateWindows() { - try { - updateWindows() - } catch (e) { - Logger.e("MangoService", "Error updating windows:", e) - } - } - - // Public functions - function switchToWorkspace(workspace) { - try { - // MangoWC uses tags 1-9, so switch to tag by ID - const tagId = workspace.idx || workspace.id || 1 - Quickshell.execDetached(["mmsg", "-d", "view", tagId.toString()]) - } catch (e) { - Logger.e("MangoService", "Failed to switch workspace:", e) - } - } - - function focusWindow(window) { - try { - // For MangoWC, we can try to focus windows by switching to their workspace - // and then using focus commands, or by cycling through windows - if (window && window.workspaceId) { - // First switch to the window's workspace/tag - Quickshell.execDetached(["mmsg", "-d", "view", window.workspaceId.toString()]) - - // Then try to focus the window by cycling or using window-specific commands - // This is a limitation of the mmsg interface - we can't directly focus by window ID - Qt.callLater(() => { - // Give the workspace switch a moment to complete, then try to find the window - // For now, we'll use a generic focus command that focuses the main window - Quickshell.execDetached(["mmsg", "-d", "focusmaster"]) - }) + function getCurrentActiveTagId() { + for (const [tagId, tagData] of Object.entries(workspaceCache)) { + if (tagData.isActive) { + return parseInt(tagId) } - } catch (e) { - Logger.e("MangoService", "Failed to focus window:", e) - } - } - - function closeWindow(window) { - try { - // Close focused window - Quickshell.execDetached(["mmsg", "-d", "killclient"]) - } catch (e) { - Logger.e("MangoService", "Failed to close window:", e) - } - } - - function logout() { - try { - Quickshell.execDetached(["mmsg", "-d", "quit"]) - } catch (e) { - Logger.e("MangoService", "Failed to logout:", e) } + return defaultWorkspaceId } } \ No newline at end of file From 3a80389ca487dd7464e7b93db5942ce81ced9b18 Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Thu, 13 Nov 2025 21:21:15 +0530 Subject: [PATCH 03/23] fix(workspace): use tag command instead of view to prevent window moving --- Services/Compositor/MangoService.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index b7c9c1c7..22e8349e 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -40,6 +40,7 @@ Item { }, action: { view: ["mmsg", "-d", "view"], + tag: ["mmsg", "-t"], focusMaster: ["mmsg", "-d", "focusmaster"], killClient: ["mmsg", "-d", "killclient"], toggleOverview: ["mmsg", "-d", "toggleoverview"], @@ -308,7 +309,7 @@ Item { function switchToWorkspace(workspace) { try { const tagId = workspace.idx || workspace.id || defaultWorkspaceId - const command = mmsgCommands.action.view.concat([tagId.toString()]) + const command = mmsgCommands.action.tag.concat([tagId.toString()]) Quickshell.execDetached(command) Logger.d("MangoService", `Switching to workspace ${tagId}`) } catch (e) { From a49f4ba009d334ac0689a2e925cdbd42aa2cd259 Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Thu, 13 Nov 2025 22:06:06 +0530 Subject: [PATCH 04/23] fix: resolve MangoService window parsing scope and add KeyboardLayoutService import --- Services/Compositor/MangoService.qml | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index 22e8349e..18c6b058 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -3,6 +3,7 @@ import Quickshell import Quickshell.Io import qs.Commons import qs.Services.UI +import qs.Services.Keyboard Item { id: root @@ -126,7 +127,7 @@ Item { onRunningChanged: { if (running) { - currentWindow = {} + windowsProcess.currentWindow = {} } } @@ -141,8 +142,8 @@ Item { const property = parts[1] const value = parts.slice(2).join(' ') - if (!currentWindow[outputName]) { - currentWindow[outputName] = { + if (!windowsProcess.currentWindow[outputName]) { + windowsProcess.currentWindow[outputName] = { id: outputName, output: outputName } @@ -150,29 +151,29 @@ Item { switch (property) { case "title": - currentWindow[outputName].title = value + windowsProcess.currentWindow[outputName].title = value break case "appid": - currentWindow[outputName].appId = value - currentWindow[outputName].class = value + windowsProcess.currentWindow[outputName].appId = value + windowsProcess.currentWindow[outputName].class = value break case "fullscreen": - currentWindow[outputName].fullscreen = (value === "1") + windowsProcess.currentWindow[outputName].fullscreen = (value === "1") break case "floating": - currentWindow[outputName].floating = (value === "1") + windowsProcess.currentWindow[outputName].floating = (value === "1") break case "x": - currentWindow[outputName].x = parseInt(value) + windowsProcess.currentWindow[outputName].x = parseInt(value) break case "y": - currentWindow[outputName].y = parseInt(value) + windowsProcess.currentWindow[outputName].y = parseInt(value) break case "width": - currentWindow[outputName].width = parseInt(value) + windowsProcess.currentWindow[outputName].width = parseInt(value) break case "height": - currentWindow[outputName].height = parseInt(value) + windowsProcess.currentWindow[outputName].height = parseInt(value) break } } @@ -181,12 +182,12 @@ Item { onExited: function (exitCode) { if (exitCode === 0) { - parseWindows(currentWindow) + parseWindows(windowsProcess.currentWindow) } else { Logger.e("MangoService", "Windows query failed:", exitCode) } accumulatedOutput = "" - currentWindow = {} + windowsProcess.currentWindow = {} } } From 06007549a34e3d70ba52f9762661bf4e87a3ee68 Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Thu, 13 Nov 2025 22:56:23 +0530 Subject: [PATCH 05/23] fix: resolve active window detection --- Services/Compositor/MangoService.qml | 72 +++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index 18c6b058..3379a925 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -28,6 +28,7 @@ Item { property string currentLayout: "" property string currentLayoutSymbol: "" property string currentKeyboardLayout: "" + property string selectedMonitor: "" // Constants readonly property var mmsgCommands: ({ @@ -281,6 +282,36 @@ Item { } } + Process { + id: monitorStateProcess + running: false + command: ["mmsg", "-g"] + + stdout: SplitParser { + onRead: function (line) { + try { + const parts = line.trim().split(/\s+/) + if (parts.length >= 3 && parts[1] === "selmon") { + const outputName = parts[0] + const isSelected = parts[2] === "1" + if (isSelected) { + selectedMonitor = outputName + Logger.d("MangoService", `Initial selected monitor: ${outputName}`) + } + } + } catch (e) { + Logger.e("MangoService", "Monitor state parsing error:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Monitor state query failed:", exitCode) + } + } + } + // Initialization function initialize() { if (initialized) { @@ -291,6 +322,8 @@ Item { try { Logger.i("MangoService", "Initializing MangoWC service...") + // Query monitor state first to establish selected monitor before parsing windows + queryMonitorState() eventStream.running = true queryWorkspaces() queryWindows() @@ -435,13 +468,18 @@ Item { for (const [outputName, data] of Object.entries(windowData)) { if (data.title || data.appId) { + // Windows from mmsg -g -c are already the focused windows for their respective outputs + // A window is focused if it's from the currently selected monitor + // If selectedMonitor is not yet set, assume first window is focused (fallback) + const isFocused = selectedMonitor ? (outputName === selectedMonitor) : (windowsList.length === 0) + const windowInfo = { id: outputName, title: data.title || "", appId: data.appId || "", class: data.appId || "", workspaceId: getCurrentActiveTagId(), - isFocused: false, + isFocused: isFocused, output: outputName, fullscreen: data.fullscreen || false, floating: data.floating || false, @@ -459,16 +497,11 @@ Item { windowsList.push(windowInfo) newWindowCache[outputName] = windowInfo - } - } - - for (let i = 0; i < windowsList.length; i++) { - const window = windowsList[i] - const outputData = monitorCache[window.output] - if (outputData && outputData.focused) { - window.isFocused = true - newFocusedIndex = i - break + + if (isFocused) { + newFocusedIndex = windowsList.length - 1 + Logger.d("MangoService", `Focused window detected: ${data.title} on ${outputName}`) + } } } @@ -530,6 +563,17 @@ Item { const eventType = parts[1] switch (eventType) { + case "selmon": + if (parts.length >= 3) { + const monitorName = parts[0] + const isSelected = parts[2] === "1" + if (isSelected) { + selectedMonitor = monitorName + Logger.d("MangoService", `Selected monitor changed to: ${monitorName}`) + } + } + updateTimer.restart() + break case "tag": case "title": case "appid": @@ -540,7 +584,6 @@ Item { case "scale_factor": case "monitor": case "client": - case "selmon": updateTimer.restart() break } @@ -567,11 +610,16 @@ Item { outputsProcess.running = true } + function queryMonitorState() { + monitorStateProcess.running = true + } + // Utilities function safeUpdate() { try { queryWorkspaces() queryWindows() + queryMonitorState() } catch (e) { Logger.e("MangoService", "Safe update failed:", e) } From 2c5c462aaaa0b1729397529021493515c676c8a2 Mon Sep 17 00:00:00 2001 From: Olaf Luijks Date: Fri, 14 Nov 2025 04:15:55 +0100 Subject: [PATCH 06/23] HostService: add user display name and use it in UI - Add username/envRealName/realName and displayName to HostService - Resolve real name from `getent passwd $USER` with NOCTALIA_REALNAME override - Use HostService.displayName on the lock screen and in the Control Center profile card --- Modules/LockScreen/LockContext.qml | 3 +- Modules/LockScreen/LockScreen.qml | 3 +- .../ControlCenter/Cards/ProfileCard.qml | 3 +- Modules/Panels/Settings/Tabs/GeneralTab.qml | 2 +- Services/System/HostService.qml | 40 +++++++++++++++++++ 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Modules/LockScreen/LockContext.qml b/Modules/LockScreen/LockContext.qml index ed31d0fa..31b07f34 100644 --- a/Modules/LockScreen/LockContext.qml +++ b/Modules/LockScreen/LockContext.qml @@ -2,6 +2,7 @@ import QtQuick import Quickshell import Quickshell.Services.Pam import qs.Commons +import qs.Services.System Scope { id: root @@ -40,7 +41,7 @@ Scope { PamContext { id: pam config: "login" - user: Quickshell.env("USER") + user: HostService.displayName onPamMessage: { Logger.i("LockContext", "PAM message:", message, "isError:", messageIsError, "responseRequired:", responseRequired) diff --git a/Modules/LockScreen/LockScreen.qml b/Modules/LockScreen/LockScreen.qml index 4bf8b4d5..b4938c52 100644 --- a/Modules/LockScreen/LockScreen.qml +++ b/Modules/LockScreen/LockScreen.qml @@ -15,6 +15,7 @@ import qs.Services.Location import qs.Services.Media import qs.Services.Compositor import qs.Services.UI +import qs.Services.System import qs.Widgets import qs.Widgets.AudioSpectrum @@ -336,7 +337,7 @@ Loader { // Welcome back + Username on one line NText { - text: I18n.tr("lock-screen.welcome-back") + " " + (Quickshell.env("USER").charAt(0).toUpperCase() + Quickshell.env("USER").slice(1)) + "!" + text: I18n.tr("lock-screen.welcome-back") + " " + HostService.displayName + "!" pointSize: Style.fontSizeXXL font.weight: Font.Medium color: Color.mOnSurface diff --git a/Modules/Panels/ControlCenter/Cards/ProfileCard.qml b/Modules/Panels/ControlCenter/Cards/ProfileCard.qml index 2a75e700..a03858f0 100644 --- a/Modules/Panels/ControlCenter/Cards/ProfileCard.qml +++ b/Modules/Panels/ControlCenter/Cards/ProfileCard.qml @@ -7,6 +7,7 @@ import Quickshell.Widgets import qs.Commons import qs.Modules.Panels.ControlCenter.Cards import qs.Modules.Panels.Settings +import qs.Services.System import qs.Services.UI import qs.Widgets @@ -37,7 +38,7 @@ NBox { Layout.fillWidth: true spacing: Style.marginXXS NText { - text: Quickshell.env("USER") || "user" + text: HostService.displayName font.weight: Style.fontWeightBold font.capitalization: Font.Capitalize } diff --git a/Modules/Panels/Settings/Tabs/GeneralTab.qml b/Modules/Panels/Settings/Tabs/GeneralTab.qml index 955ed3a7..4e7e5732 100644 --- a/Modules/Panels/Settings/Tabs/GeneralTab.qml +++ b/Modules/Panels/Settings/Tabs/GeneralTab.qml @@ -33,7 +33,7 @@ ColumnLayout { NTextInputButton { label: I18n.tr("settings.general.profile.picture.label", { - "user": Quickshell.env("USER" || "User") + "user": HostService.displayName }) description: I18n.tr("settings.general.profile.picture.description") text: Settings.data.general.avatarImage diff --git a/Services/System/HostService.qml b/Services/System/HostService.qml index adcd766d..6a6129e7 100644 --- a/Services/System/HostService.qml +++ b/Services/System/HostService.qml @@ -14,6 +14,28 @@ Singleton { property bool isNixOS: false property bool isReady: false + // User info + readonly property string username: (Quickshell.env("USER") || "") + readonly property string envRealName: (Quickshell.env("NOCTALIA_REALNAME") || "") + property string realName: "" + + readonly property string displayName: { + // Explicit override + if (envRealName && envRealName.length > 0) + return envRealName + + // Name from getent + if (realName && realName.length > 0) + return realName + + // Fallback: capitalized $USER + if (username && username.length > 0) + return username.charAt(0).toUpperCase() + username.slice(1) + + // Last resort: placeholder + return "User" + } + function init() { Logger.i("HostService", "Service started") } @@ -111,4 +133,22 @@ Singleton { stdout: StdioCollector {} stderr: StdioCollector {} } + + // Resolve GECOS real name once on startup + Process { + id: realNameProcess + command: ["sh", "-c", "getent passwd \"$USER\" | cut -d: -f5 | cut -d, -f1"] + running: true + + stdout: StdioCollector { + onStreamFinished: { + const name = String(text || "").trim() + if (name.length > 0) { + root.realName = name + Logger.i("HostService", "resolved real name", name) + } + } + } + stderr: StdioCollector {} + } } From 96ae2c0d6fe26a64244659c8654535c553e9c45e Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 07:40:15 +0100 Subject: [PATCH 07/23] Matugen/Code: add VSCodium support --- Assets/Translations/de.json | 2 +- Assets/Translations/en.json | 2 +- Assets/Translations/es.json | 2 +- Assets/Translations/fr.json | 2 +- Assets/Translations/nl.json | 2 +- Assets/Translations/pt.json | 2 +- Assets/Translations/ru.json | 2 +- Assets/Translations/tr.json | 2 +- Assets/Translations/uk-UA.json | 2 +- Assets/Translations/zh-CN.json | 2 +- .../Panels/Settings/Tabs/ColorSchemeTab.qml | 49 +++++++++++--- Services/System/ProgramCheckerService.qml | 66 ++++++++++++++++++- Services/Theming/TemplateProcessor.qml | 59 +++++++++++++++++ Services/Theming/TemplateRegistry.qml | 35 +++++++++- 14 files changed, 206 insertions(+), 23 deletions(-) diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index a40c3374..0474b777 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Schreibe {Dateipfad}. Das Hyprluna-Theme muss manuell installiert und aktiviert werden", - "description-missing": "Benötigt die Installation von {app}" + "description-missing": "Kein Code-Client erkannt. Installieren Sie VSCode oder VSCodium." }, "description": "Anwendungsspezifisches Theming.", "discord": { diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 5c4ab9f1..b92c800e 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Write {filepath}. Hyprluna theme needs to be installed and activated manually.", - "description-missing": "Requires {app} to be installed" + "description-missing": "No Code client detected. Install VSCode or VSCodium." }, "description": "Application-specific theming.", "discord": { diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index 76decb25..9076a78d 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Escribe {filepath}. El tema Hyprluna debe ser instalado y activado manualmente.", - "description-missing": "Requiere que {app} esté instalado/a." + "description-missing": "No se detectó cliente de Code. Instala VSCode o VSCodium." }, "description": "Tematización específica de aplicaciones.", "discord": { diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index 6f0a1bae..10e96498 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Écrire {filepath}. Le thème Hyprluna doit être installé et activé manuellement.", - "description-missing": "Nécessite l'installation de {app}" + "description-missing": "Aucun client Code détecté. Installez VSCode ou VSCodium." }, "description": "Thématisation spécifique aux applications.", "discord": { diff --git a/Assets/Translations/nl.json b/Assets/Translations/nl.json index f1f74974..0568efee 100644 --- a/Assets/Translations/nl.json +++ b/Assets/Translations/nl.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Schrijf {filepath}. Het Hyprluna-thema moet handmatig worden geïnstalleerd en geactiveerd.", - "description-missing": "Vereist dat {app} is geïnstalleerd." + "description-missing": "Geen Code-client gedetecteerd. Installeer VSCode of VSCodium." }, "description": "Toepassingsspecifieke theming.", "discord": { diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index fac180ae..7d62b4ae 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Escreva em {filepath}. O tema Hyprluna precisa ser instalado e ativado manualmente.", - "description-missing": "Requer que o {app} esteja instalado." + "description-missing": "Nenhum cliente Code detectado. Instale VSCode ou VSCodium." }, "description": "Tematização específica de aplicativos.", "discord": { diff --git a/Assets/Translations/ru.json b/Assets/Translations/ru.json index 45bb6fe6..64648c1f 100644 --- a/Assets/Translations/ru.json +++ b/Assets/Translations/ru.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Записать {filepath}. Тему Hyprluna нужно установить и активировать вручную.", - "description-missing": "Требуется установка {app}" + "description-missing": "Клиент Code не обнаружен. Установите VSCode или VSCodium." }, "description": "Тематика для конкретных приложений.", "discord": { diff --git a/Assets/Translations/tr.json b/Assets/Translations/tr.json index 9fafd582..30335a5c 100644 --- a/Assets/Translations/tr.json +++ b/Assets/Translations/tr.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "{filepath} dosyasına yaz. Hyprluna temasının kurulu ve manuel olarak etkinleştirilmiş olması gerekir.", - "description-missing": "Kurulum için {app} gereklidir" + "description-missing": "Code istemcisi tespit edilmedi. VSCode veya VSCodium kurun." }, "description": "Uygulamaya özel temalandırma.", "discord": { diff --git a/Assets/Translations/uk-UA.json b/Assets/Translations/uk-UA.json index e8eb376a..ef948d3e 100644 --- a/Assets/Translations/uk-UA.json +++ b/Assets/Translations/uk-UA.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "Записати {filepath}. Тему Hyprluna потрібно встановити та активувати вручну.", - "description-missing": "Потрібна установка {app}" + "description-missing": "Клієнт Code не виявлено. Встановіть VSCode або VSCodium." }, "description": "Оформлення окремих програм.", "discord": { diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index c72c6728..8f16bd51 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -880,7 +880,7 @@ "programs": { "code": { "description": "写入 {filepath}。Hyprluna 主题需要手动安装和激活。", - "description-missing": "需要安装 {app}" + "description-missing": "未检测到 Code 客户端。请安装 VSCode 或 VSCodium。" }, "description": "应用程序特定主题。", "discord": { diff --git a/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml b/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml index d11e6e68..dc8e59df 100644 --- a/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml +++ b/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml @@ -740,19 +740,48 @@ ColumnLayout { } } + // Code clients - single toggle with dynamic description NCheckbox { + id: codeToggle label: "Code" - description: ProgramCheckerService.codeAvailable ? I18n.tr("settings.color-scheme.templates.programs.code.description", { - "filepath": "~/.vscode/extensions/hyprluna.hyprluna-theme-1.0.2/themes/hyprluna.json" - }) : I18n.tr("settings.color-scheme.templates.programs.code.description-missing", { - "app": "code" - }) - checked: Settings.data.templates.code - enabled: ProgramCheckerService.codeAvailable - opacity: ProgramCheckerService.codeAvailable ? 1.0 : 0.6 + description: { + if (ProgramCheckerService.availableCodeClients.length === 0) { + return I18n.tr("settings.color-scheme.templates.programs.code.description-missing") + } else { + // Show detected clients + var clientInfo = [] + for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) { + var client = ProgramCheckerService.availableCodeClients[i] + // Capitalize first letter and format nicely + var clientName = client.name === "code" ? "VSCode" : "VSCodium" + clientInfo.push(clientName) + } + return "Detected: " + clientInfo.join(", ") + } + } + Layout.fillWidth: true + Layout.preferredWidth: -1 + checked: { + // Check if any Code client template is enabled + var anyEnabled = false + for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) { + var client = ProgramCheckerService.availableCodeClients[i] + if (Settings.data.templates["code_" + client.name]) { + anyEnabled = true + break + } + } + return anyEnabled + } + enabled: ProgramCheckerService.availableCodeClients.length > 0 + opacity: ProgramCheckerService.availableCodeClients.length > 0 ? 1.0 : 0.6 onToggled: checked => { - if (ProgramCheckerService.codeAvailable) { - Settings.data.templates.code = checked + // Enable/disable all detected Code clients + for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) { + var client = ProgramCheckerService.availableCodeClients[i] + Settings.data.templates["code_" + client.name] = checked + } + if (ProgramCheckerService.availableCodeClients.length > 0) { AppThemeService.generate() } } diff --git a/Services/System/ProgramCheckerService.qml b/Services/System/ProgramCheckerService.qml index 10a2eff0..17dd6983 100644 --- a/Services/System/ProgramCheckerService.qml +++ b/Services/System/ProgramCheckerService.qml @@ -31,6 +31,9 @@ Singleton { // Discord client auto-detection property var availableDiscordClients: [] + // Code client auto-detection + property var availableCodeClients: [] + // Signal emitted when all checks are complete signal checksCompleted @@ -97,6 +100,66 @@ Singleton { stderr: StdioCollector {} } + // Function to detect Code client by checking config directories + function detectCodeClient() { + // Build shell script to check each client + var scriptParts = ["available_clients=\"\";"] + + for (var i = 0; i < TemplateRegistry.codeClients.length; i++) { + var client = TemplateRegistry.codeClients[i] + var clientName = client.name + var configPath = client.configPath + + // Check if the config directory exists + scriptParts.push("if [ -d \"$HOME" + configPath.substring(1) + "\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;") + } + + scriptParts.push("echo \"$available_clients\"") + + // Use a Process to check directory existence for all clients + codeDetector.command = ["sh", "-c", scriptParts.join(" ")] + codeDetector.running = true + } + + // Process to detect Code client directories + Process { + id: codeDetector + running: false + + onExited: function (exitCode) { + availableCodeClients = [] + + if (exitCode === 0) { + var detectedClients = stdout.text.trim().split(/\s+/).filter(function (client) { + return client.length > 0 + }) + + if (detectedClients.length > 0) { + // Build list of available clients + for (var i = 0; i < detectedClients.length; i++) { + var clientName = detectedClients[i] + for (var j = 0; j < TemplateRegistry.codeClients.length; j++) { + var client = TemplateRegistry.codeClients[j] + if (client.name === clientName) { + availableCodeClients.push(client) + break + } + } + } + + Logger.i("ProgramChecker", "Detected Code clients:", detectedClients.join(", ")) + } + } + + if (availableCodeClients.length === 0) { + Logger.d("ProgramChecker", "No Code clients detected") + } + } + + stdout: StdioCollector {} + stderr: StdioCollector {} + } + // Programs to check - maps property names to commands readonly property var programsToCheck: ({ "matugenAvailable": ["which", "matugen"], @@ -140,8 +203,9 @@ Singleton { // Check next program or emit completion signal if (root.completedChecks >= root.totalChecks) { - // Run Discord client detection after all checks are complete + // Run Discord and Code client detection after all checks are complete root.detectDiscordClient() + root.detectCodeClient() root.checksCompleted() } else { root.checkNextProgram() diff --git a/Services/Theming/TemplateProcessor.qml b/Services/Theming/TemplateProcessor.qml index 63e059ed..9992bf1b 100644 --- a/Services/Theming/TemplateProcessor.qml +++ b/Services/Theming/TemplateProcessor.qml @@ -114,6 +114,18 @@ Singleton { } }) } + } else if (app.id === "code") { + // Handle Code clients specially + if (Settings.data.templates.code) { + app.clients.forEach(client => { + // Check if this specific client is detected + if (isCodeClientEnabled(client.name)) { + lines.push(`\n[templates.code_${client.name}]`) + lines.push(`input_path = "${Quickshell.shellDir}/Assets/MatugenTemplates/${app.input}"`) + lines.push(`output_path = "${client.path}"`) + } + }) + } } else { // Handle regular apps if (Settings.data.templates[app.id]) { @@ -140,6 +152,16 @@ Singleton { return false } + function isCodeClientEnabled(clientName) { + // Check ProgramCheckerService to see if client is detected + for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) { + if (ProgramCheckerService.availableCodeClients[i].name === clientName) { + return true + } + } + return false + } + function buildMatugenScript(content, wallpaper, mode) { const delimiter = "MATUGEN_CONFIG_EOF_" + Math.random().toString(36).substr(2, 9) const pathEsc = dynamicConfigPath.replace(/'/g, "'\\''") @@ -163,6 +185,10 @@ Singleton { if (Settings.data.templates.discord) { script += processDiscordClients(app, colors, mode, homeDir) } + } else if (app.id === "code") { + if (Settings.data.templates.code) { + script += processCodeClients(app, colors, mode, homeDir) + } } else { if (Settings.data.templates[app.id]) { script += processTemplate(app, colors, mode, homeDir) @@ -198,6 +224,39 @@ Singleton { return script } + function processCodeClients(codeApp, colors, mode, homeDir) { + let script = "" + const palette = ColorPaletteGenerator.generatePalette(colors, Settings.data.colorSchemes.darkMode, false) + + codeApp.clients.forEach(client => { + if (!isCodeClientEnabled(client.name)) + return + + const templatePath = `${Quickshell.shellDir}/Assets/MatugenTemplates/${codeApp.input}` + const outputPath = client.path.replace("~", homeDir) + const outputDir = outputPath.substring(0, outputPath.lastIndexOf('/')) + + // Extract base config directory for checking + var baseConfigDir = "" + if (client.name === "code") { + baseConfigDir = "~/.vscode".replace("~", homeDir) + } else if (client.name === "codium") { + baseConfigDir = "~/.vscode-oss".replace("~", homeDir) + } + + script += `\n` + script += `if [ -d "${baseConfigDir}" ]; then\n` + script += ` mkdir -p ${outputDir}\n` + script += ` cp '${templatePath}' '${outputPath}'\n` + script += ` ${replaceColorsInFile(outputPath, palette)}` + script += `else\n` + script += ` echo "Code client ${client.name} not found at ${baseConfigDir}, skipping"\n` + script += `fi\n` + }) + + return script + } + function processTemplate(app, colors, mode, homeDir) { const palette = ColorPaletteGenerator.generatePalette(colors, Settings.data.colorSchemes.darkMode, app.strict || false) let script = "" diff --git a/Services/Theming/TemplateRegistry.qml b/Services/Theming/TemplateRegistry.qml index ebb67a01..b810f78e 100644 --- a/Services/Theming/TemplateRegistry.qml +++ b/Services/Theming/TemplateRegistry.qml @@ -142,14 +142,18 @@ Singleton { "path": "~/.config/discord", "requiresThemesFolder": true }] - }, // VSCode with hardcoded path (requirement #5) + }, { "id": "code", "name": "VSCode", "category": "applications", "input": "code.json", - "outputs": [{ + "clients": [{ + "name": "code", "path": "~/.vscode/extensions/hyprluna.hyprluna-theme-1.0.2/themes/hyprluna.json" + }, { + "name": "codium", + "path": "~/.vscode-oss/extensions/hyprluna.hyprluna-theme-1.0.2/themes/hyprluna.json" }] }, { "id": "spicetify", @@ -179,6 +183,33 @@ Singleton { return clients } + // Extract Code clients for ProgramCheckerService compatibility + readonly property var codeClients: { + var clients = [] + var codeApp = applications.find(app => app.id === "code") + if (codeApp && codeApp.clients) { + codeApp.clients.forEach(client => { + // Extract base config directory from theme path + var themePath = client.path + var baseConfigDir = "" + if (client.name === "code") { + // For VSCode: ~/.vscode/extensions/... -> ~/.vscode + baseConfigDir = "~/.vscode" + } else if (client.name === "codium") { + // For VSCodium: ~/.vscode-oss/extensions/... -> ~/.vscode-oss + baseConfigDir = "~/.vscode-oss" + } + clients.push({ + "name": client.name, + "configPath": baseConfigDir, + "themePath": themePath, + "requiresThemesFolder": false + }) + }) + } + return clients + } + // Build user templates TOML content function buildUserTemplatesToml() { var lines = [] From 2d99a2c233c713020ab1637ea380c5df35ac9e21 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 07:56:20 +0100 Subject: [PATCH 08/23] Matugen/Code: fix VSCodium support --- Commons/Settings.qml | 3 +++ Modules/Panels/Settings/Tabs/ColorSchemeTab.qml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 43e04798..868b380c 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -439,6 +439,9 @@ Singleton { property bool spicetify: false property bool enableUserTemplates: false + property bool code_code: false + property bool code_codium: false + property bool discord_vesktop: false // To be deleted soon property bool discord_webcord: false // To be deleted soon property bool discord_armcord: false // To be deleted soon diff --git a/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml b/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml index dc8e59df..ca9c23f8 100644 --- a/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml +++ b/Modules/Panels/Settings/Tabs/ColorSchemeTab.qml @@ -677,6 +677,8 @@ ColumnLayout { enabled: ProgramCheckerService.availableDiscordClients.length > 0 opacity: ProgramCheckerService.availableDiscordClients.length > 0 ? 1.0 : 0.6 onToggled: checked => { + // Set unified discord property + Settings.data.templates.discord = checked // Enable/disable all detected Discord clients for (var i = 0; i < ProgramCheckerService.availableDiscordClients.length; i++) { var client = ProgramCheckerService.availableDiscordClients[i] @@ -776,6 +778,8 @@ ColumnLayout { enabled: ProgramCheckerService.availableCodeClients.length > 0 opacity: ProgramCheckerService.availableCodeClients.length > 0 ? 1.0 : 0.6 onToggled: checked => { + // Set unified code property + Settings.data.templates.code = checked // Enable/disable all detected Code clients for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) { var client = ProgramCheckerService.availableCodeClients[i] From 5bd844ec51c66c85beda5c48d5ac3b381b94dc4c Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 08:18:05 +0100 Subject: [PATCH 09/23] Matugen/Discord: fix Vencord path --- Services/System/ProgramCheckerService.qml | 8 ++++++-- Services/Theming/TemplateRegistry.qml | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Services/System/ProgramCheckerService.qml b/Services/System/ProgramCheckerService.qml index 17dd6983..0d2cd0c8 100644 --- a/Services/System/ProgramCheckerService.qml +++ b/Services/System/ProgramCheckerService.qml @@ -45,12 +45,16 @@ Singleton { for (var i = 0; i < TemplateRegistry.discordClients.length; i++) { var client = TemplateRegistry.discordClients[i] var clientName = client.name + var configPath = client.configPath + + // Use the actual config path from the client, removing ~ prefix + var checkPath = configPath.startsWith("~") ? configPath.substring(2) : configPath.substring(1) // Check if this client requires themes folder to exist if (client.requiresThemesFolder) { - scriptParts.push("if [ -d \"$HOME/.config/" + clientName + "/themes\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;") + scriptParts.push("if [ -d \"$HOME/" + checkPath + "/themes\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;") } else { - scriptParts.push("if [ -d \"$HOME/.config/" + clientName + "\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;") + scriptParts.push("if [ -d \"$HOME/" + checkPath + "\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;") } } diff --git a/Services/Theming/TemplateRegistry.qml b/Services/Theming/TemplateRegistry.qml index b810f78e..24da2974 100644 --- a/Services/Theming/TemplateRegistry.qml +++ b/Services/Theming/TemplateRegistry.qml @@ -139,8 +139,8 @@ Singleton { "requiresThemesFolder": false }, { "name": "vencord", - "path": "~/.config/discord", - "requiresThemesFolder": true + "path": "~/.config/Vencord", + "requiresThemesFolder": false }] }, { From 68e83f4d63187de84d9b33fb3b7cb9c7e6e93dfa Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 08:21:54 +0100 Subject: [PATCH 10/23] Matugen/Discord: fix Vencord again --- Commons/Settings.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 868b380c..d03d3a8b 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -448,6 +448,7 @@ Singleton { property bool discord_equibop: false // To be deleted soon property bool discord_lightcord: false // To be deleted soon property bool discord_dorion: false // To be deleted soon + property bool discord_vencord: false // To be deleted soon } // night light @@ -660,7 +661,7 @@ Singleton { var anyDiscordEnabled = false // Check if any Discord client was enabled - const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion"] + const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion", "discord_vencord"] for (var i = 0; i < discordClients.length; i++) { if (adapter.templates[discordClients[i]]) { From 545e72c2567eaf9a28c9ef9a754e080f929fb64c Mon Sep 17 00:00:00 2001 From: Olaf Luijks Date: Fri, 14 Nov 2025 10:56:39 +0100 Subject: [PATCH 11/23] Bar/Widgets: hide volume tooltips while adjusting --- Modules/Bar/Widgets/Microphone.qml | 7 +++++++ Modules/Bar/Widgets/Volume.qml | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/Modules/Bar/Widgets/Microphone.qml b/Modules/Bar/Widgets/Microphone.qml index d384cfb5..2c4ae1fe 100644 --- a/Modules/Bar/Widgets/Microphone.qml +++ b/Modules/Bar/Widgets/Microphone.qml @@ -50,6 +50,9 @@ Item { // Ignore the first volume change firstInputVolumeReceived = true } else { + // If a tooltip is visible while we show the pill + // hide it so it doesn't overlap the volume slider. + TooltipService.hide() pill.show() externalHideTimer.restart() } @@ -65,6 +68,7 @@ Item { // Ignore the first mute change firstInputVolumeReceived = true } else { + TooltipService.hide() pill.show() externalHideTimer.restart() } @@ -96,6 +100,9 @@ Item { }) onWheel: function (delta) { + // As soon as we start scrolling to adjust volume, hide the tooltip + TooltipService.hide() + wheelAccumulator += delta if (wheelAccumulator >= 120) { wheelAccumulator = 0 diff --git a/Modules/Bar/Widgets/Volume.qml b/Modules/Bar/Widgets/Volume.qml index 9fb72180..c43a3380 100644 --- a/Modules/Bar/Widgets/Volume.qml +++ b/Modules/Bar/Widgets/Volume.qml @@ -50,6 +50,8 @@ Item { // Ignore the first volume change firstVolumeReceived = true } else { + // Hide any tooltip while the pill is visible / being updated + TooltipService.hide() pill.show() externalHideTimer.restart() } @@ -81,6 +83,9 @@ Item { }) onWheel: function (delta) { + // Hide tooltip as soon as the user starts scrolling to adjust volume + TooltipService.hide() + wheelAccumulator += delta if (wheelAccumulator >= 120) { wheelAccumulator = 0 From ee22bb9e21ebf67ef29bac88187556e8435208ab Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Fri, 14 Nov 2025 15:29:46 +0530 Subject: [PATCH 12/23] feat: add multi-monitor support --- Services/Compositor/MangoService.qml | 215 +++++++++++++++++++++------ 1 file changed, 169 insertions(+), 46 deletions(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index 3379a925..64d0676c 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -38,16 +38,17 @@ Item { layout: ["mmsg", "-g", "-l"], keyboard: ["mmsg", "-g", "-k"], outputs: ["mmsg", "-g", "-A"], + monitors: ["mmsg", "-g", "-o"], eventStream: ["mmsg", "-w"] }, action: { - view: ["mmsg", "-d", "view"], - tag: ["mmsg", "-t"], - focusMaster: ["mmsg", "-d", "focusmaster"], - killClient: ["mmsg", "-d", "killclient"], - toggleOverview: ["mmsg", "-d", "toggleoverview"], - setLayout: ["mmsg", "-d", "setlayout"], - quit: ["mmsg", "-d", "quit"] + view: ["mmsg", "-s", "-d", "view"], + tag: ["mmsg", "-s", "-t"], + focusMaster: ["mmsg", "-s", "-d", "focusmaster"], + killClient: ["mmsg", "-s", "-d", "killclient"], + toggleOverview: ["mmsg", "-s", "-d", "toggleoverview"], + setLayout: ["mmsg", "-s", "-d", "setlayout"], + quit: ["mmsg", "-s", "-q"] } }) @@ -285,7 +286,7 @@ Item { Process { id: monitorStateProcess running: false - command: ["mmsg", "-g"] + command: mmsgCommands.query.monitors stdout: SplitParser { onRead: function (line) { @@ -312,6 +313,38 @@ Item { } } + Process { + id: outputEnumProcess + running: false + command: ["mmsg", "-g", "-O"] + + stdout: SplitParser { + onRead: function (line) { + try { + const trimmed = line.trim() + // Handle output enumeration format: "+ eDP-1" + const outputName = trimmed.replace(/^\+\s*/, '') + if (outputName && !monitorCache[outputName]) { + monitorCache[outputName] = { + name: outputName, + scale: 1.0, + active: false, + focused: false + } + } + } catch (e) { + Logger.e("MangoService", "Output enumeration error:", e, line) + } + } + } + + onExited: function (exitCode) { + if (exitCode !== 0) { + Logger.e("MangoService", "Output enumeration failed:", exitCode) + } + } + } + // Initialization function initialize() { if (initialized) { @@ -323,6 +356,7 @@ Item { Logger.i("MangoService", "Initializing MangoWC service...") // Query monitor state first to establish selected monitor before parsing windows + queryOutputEnum() queryMonitorState() eventStream.running = true queryWorkspaces() @@ -343,9 +377,16 @@ Item { function switchToWorkspace(workspace) { try { const tagId = workspace.idx || workspace.id || defaultWorkspaceId - const command = mmsgCommands.action.tag.concat([tagId.toString()]) + const outputName = workspace.output || selectedMonitor || "" + let command = [...mmsgCommands.action.tag] + + if (outputName) { + command.push("-o", outputName) + } + command.push(tagId.toString()) + Quickshell.execDetached(command) - Logger.d("MangoService", `Switching to workspace ${tagId}`) + Logger.d("MangoService", `Switching to workspace ${tagId} on ${outputName || 'default output'}`) } catch (e) { Logger.e("MangoService", "Failed to switch workspace:", e) } @@ -354,12 +395,15 @@ Item { // Window operations function focusWindow(window) { try { - if (window && window.workspaceId) { - const command = mmsgCommands.action.view.concat([window.workspaceId.toString()]) + if (window && window.output) { + let command = [...mmsgCommands.action.view] + command.push("-o", window.output, window.workspaceId.toString()) Quickshell.execDetached(command) Qt.callLater(() => { - Quickshell.execDetached(mmsgCommands.action.focusMaster) + let focusCommand = [...mmsgCommands.action.focusMaster] + focusCommand.push("-o", window.output) + Quickshell.execDetached(focusCommand) }) } } catch (e) { @@ -367,9 +411,13 @@ Item { } } - function closeWindow() { + function closeWindow(window) { try { - Quickshell.execDetached(mmsgCommands.action.killClient) + const command = [...mmsgCommands.action.killClient] + if (selectedMonitor) { + command.push("-o", selectedMonitor) + } + Quickshell.execDetached(command) } catch (e) { Logger.e("MangoService", "Failed to close window:", e) } @@ -378,7 +426,11 @@ Item { // MangoWC-specific operations function toggleOverview() { try { - Quickshell.execDetached(mmsgCommands.action.toggleOverview) + const command = [...mmsgCommands.action.toggleOverview] + if (selectedMonitor) { + command.push("-o", selectedMonitor) + } + Quickshell.execDetached(command) } catch (e) { Logger.e("MangoService", "Failed to toggle overview:", e) } @@ -386,7 +438,8 @@ Item { function setLayout(layoutName) { try { - const command = mmsgCommands.action.setLayout.concat([layoutName]) + const command = [...mmsgCommands.action.setLayout] + command.push(layoutName) Quickshell.execDetached(command) } catch (e) { Logger.e("MangoService", "Failed to set layout:", e) @@ -406,14 +459,15 @@ Item { const lines = output.trim().split('\n') const workspacesList = [] const newWorkspaceCache = {} + let outputClients = {} for (const line of lines) { const trimmed = line.trim() if (!trimmed) continue - const match = trimmed.match(/^(\S+)\s+tag\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) - if (match) { - const [, outputName, tagNum, state, clients, focused] = match + const tagMatch = trimmed.match(/^(\S+)\s+tag\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/) + if (tagMatch) { + const [, outputName, tagNum, state, clients, focused] = tagMatch const tagId = parseInt(tagNum) const isActive = (parseInt(state) & 1) !== 0 @@ -421,22 +475,66 @@ Item { const isOccupied = parseInt(clients) > 0 const isFocused = isActive && parseInt(focused) === 1 + if (!outputClients[outputName]) { + outputClients[outputName] = 0 + } + const workspaceData = { id: tagId, idx: tagId, name: tagId.toString(), output: outputName, isActive: isActive, - isFocused: isFocused, + isFocused: isFocused && (outputName === selectedMonitor), isUrgent: isUrgent, isOccupied: isOccupied, clients: parseInt(clients) } - newWorkspaceCache[tagId] = workspaceData + newWorkspaceCache[`${outputName}-${tagId}`] = workspaceData workspacesList.push(workspaceData) } + const clientsMatch = trimmed.match(/^(\S+)\s+clients\s+(\d+)$/) + if (clientsMatch) { + const [, outputName, clientCount] = clientsMatch + outputClients[outputName] = parseInt(clientCount) + } + + const tagsMatch = trimmed.match(/^(\S+)\s+tags\s+(\d+)\s+(\d+)\s+(\d+)$/) + if (tagsMatch) { + const [, outputName, occ, seltags, urg] = tagsMatch + // Parse binary tag states for comprehensive workspace info + const occBits = occ.padStart(9, '0') + const selBits = seltags.padStart(9, '0') + const urgBits = urg.padStart(9, '0') + + for (let i = 0; i < 9; i++) { + const tagId = i + 1 + const isActive = selBits[8-i] === '1' + const isUrgent = urgBits[8-i] === '1' + const isOccupied = occBits[8-i] === '1' + + const workspaceData = { + id: tagId, + idx: tagId, + name: tagId.toString(), + output: outputName, + isActive: isActive, + isFocused: false, // Will be determined by selected monitor + isUrgent: isUrgent, + isOccupied: isOccupied, + clients: 0 // Will be updated by tag-specific data + } + + const key = `${outputName}-${tagId}` + if (!newWorkspaceCache[key]) { + newWorkspaceCache[key] = workspaceData + workspacesList.push(workspaceData) + } + } + } + const layoutMatch = trimmed.match(/^(\S+)\s+layout\s+(\S+)$/) if (layoutMatch) { const [, , layoutSymbol] = layoutMatch @@ -444,21 +542,21 @@ Item { } } - if (JSON.stringify(newWorkspaceCache) !== JSON.stringify(workspaceCache)) { - workspaceCache = newWorkspaceCache - - workspacesList.sort((a, b) => { - if (a.id !== b.id) return a.id - b.id - return a.output.localeCompare(b.output) - }) + if (JSON.stringify(newWorkspaceCache) !== JSON.stringify(workspaceCache)) { + workspaceCache = newWorkspaceCache + + workspacesList.sort((a, b) => { + if (a.id !== b.id) return a.id - b.id + return a.output.localeCompare(b.output) + }) - workspaces.clear() - for (var i = 0; i < workspacesList.length; i++) { - workspaces.append(workspacesList[i]) + workspaces.clear() + for (var i = 0; i < workspacesList.length; i++) { + workspaces.append(workspacesList[i]) + } + + workspaceChanged() } - - workspaceChanged() - } } function parseWindows(windowData) { @@ -468,17 +566,25 @@ Item { for (const [outputName, data] of Object.entries(windowData)) { if (data.title || data.appId) { - // Windows from mmsg -g -c are already the focused windows for their respective outputs + // Windows from mmsg -g -o -c are the focused windows for their respective outputs // A window is focused if it's from the currently selected monitor - // If selectedMonitor is not yet set, assume first window is focused (fallback) - const isFocused = selectedMonitor ? (outputName === selectedMonitor) : (windowsList.length === 0) + const isFocused = (outputName === selectedMonitor) + + // Get the active tag for this output + let activeTagId = defaultWorkspaceId + for (const [key, tagData] of Object.entries(workspaceCache)) { + if (tagData.output === outputName && tagData.isActive) { + activeTagId = tagData.id + break + } + } const windowInfo = { - id: outputName, + id: `${outputName}-${data.appId || 'unknown'}`, title: data.title || "", appId: data.appId || "", class: data.appId || "", - workspaceId: getCurrentActiveTagId(), + workspaceId: activeTagId, isFocused: isFocused, output: outputName, fullscreen: data.fullscreen || false, @@ -496,7 +602,7 @@ Item { } windowsList.push(windowInfo) - newWindowCache[outputName] = windowInfo + newWindowCache[windowInfo.id] = windowInfo if (isFocused) { newFocusedIndex = windowsList.length - 1 @@ -582,8 +688,11 @@ Item { case "layout": case "kb_layout": case "scale_factor": - case "monitor": - case "client": + case "toggle": + case "last_layer": + case "keymode": + case "clients": + case "tags": updateTimer.restart() break } @@ -610,6 +719,14 @@ Item { outputsProcess.running = true } + function queryDisplayScales() { + queryOutputs() + } + + function queryOutputEnum() { + outputEnumProcess.running = true + } + function queryMonitorState() { monitorStateProcess.running = true } @@ -626,11 +743,17 @@ Item { } function getCurrentActiveTagId() { - for (const [tagId, tagData] of Object.entries(workspaceCache)) { + for (const [key, tagData] of Object.entries(workspaceCache)) { + if (tagData.isActive && tagData.output === selectedMonitor) { + return tagData.id + } + } + // Fallback to any active tag if no selected monitor match + for (const [key, tagData] of Object.entries(workspaceCache)) { if (tagData.isActive) { - return parseInt(tagId) + return tagData.id } } return defaultWorkspaceId } -} \ No newline at end of file +} From 95d252a9496b3bcd2aab343dbd7400d5385879ea Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Fri, 14 Nov 2025 17:05:34 +0530 Subject: [PATCH 13/23] fix: single monitor support by conditional -o usage --- Services/Compositor/MangoService.qml | 288 +++++++++++++++------------ 1 file changed, 164 insertions(+), 124 deletions(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index 64d0676c..23a9fc84 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -5,33 +5,36 @@ import qs.Commons import qs.Services.UI import qs.Services.Keyboard +// MangoService integrates with MangoWC compositor using mmsg IPC commands +// for real-time window management, workspace control, and state monitoring + Item { id: root - // Properties matching facade interface + // Facade interface properties property ListModel workspaces: ListModel {} property var windows: [] property int focusedWindowIndex: -1 - // Signals matching facade interface + // Facade interface signals signal workspaceChanged signal activeWindowChanged signal windowListChanged signal displayScalesChanged - // Mango-specific properties - property bool initialized: false - property bool overviewActive: false - property var workspaceCache: ({}) - property var windowCache: ({}) - property var monitorCache: ({}) - property string currentLayout: "" - property string currentLayoutSymbol: "" - property string currentKeyboardLayout: "" - property string selectedMonitor: "" + // MangoWC-specific state + property bool initialized: false + property bool overviewActive: false + property var workspaceCache: ({}) // Cache for workspace data to detect changes + property var windowCache: ({}) // Cache for window data to detect changes + property var monitorCache: ({}) // Cache for monitor/scale data + property string currentLayout: "" // Current layout name + property string currentLayoutSymbol: "" // Current layout symbol (e.g., 'S' for scroller) + property string currentKeyboardLayout: "" // Current keyboard layout name + property string selectedMonitor: "" // Currently selected/focused monitor - // Constants - readonly property var mmsgCommands: ({ + // mmsg command templates for MangoWC IPC (mmsg is the MangoWC message interface) + readonly property var mmsgCommands: ({ query: { workspaces: ["mmsg", "-g", "-t"], windows: ["mmsg", "-g", "-c"], @@ -52,18 +55,20 @@ Item { } }) - readonly property string overviewLayoutSymbol: "󰃇" - readonly property int defaultWorkspaceId: 1 + readonly property string overviewLayoutSymbol: "󰃇" // Symbol representing overview layout + readonly property int defaultWorkspaceId: 1 // Default workspace ID when none specified - // Debounce timer for updates - Timer { - id: updateTimer - interval: 50 - repeat: false - onTriggered: safeUpdate() - } + // Debounce timer for rapid state changes to avoid excessive updates + Timer { + id: updateTimer + interval: 50 + repeat: false + onTriggered: safeUpdate() + } - // Event stream for real-time updates + + // Event stream process for real-time MangoWC state monitoring using mmsg -w + // Monitors events: workspace changes, window focus/movement, layout changes, monitor selection Process { id: eventStream running: false @@ -87,22 +92,24 @@ Item { } } - Timer { - id: restartTimer - interval: 1000 - onTriggered: { - if (initialized) { - eventStream.running = true - } - } - } + // Restart timer for event stream recovery on failure + Timer { + id: restartTimer + interval: 1000 + onTriggered: { + if (initialized) { + eventStream.running = true + } + } + } - // Query processes - Process { - id: workspacesProcess - running: false - command: mmsgCommands.query.workspaces - property string accumulatedOutput: "" + + // Process to query workspaces using mmsg -g -t + Process { + id: workspacesProcess + running: false + command: mmsgCommands.query.workspaces + property string accumulatedOutput: "" stdout: SplitParser { onRead: function (line) { @@ -120,12 +127,13 @@ Item { } } - Process { - id: windowsProcess - running: false - command: mmsgCommands.query.windows - property string accumulatedOutput: "" - property var currentWindow: ({}) + // Process to query windows using mmsg -g -c + Process { + id: windowsProcess + running: false + command: mmsgCommands.query.windows + property string accumulatedOutput: "" + property var currentWindow: ({}) onRunningChanged: { if (running) { @@ -193,10 +201,11 @@ Item { } } - Process { - id: layoutProcess - running: false - command: mmsgCommands.query.layout + // Process to query current layout using mmsg -g -l + Process { + id: layoutProcess + running: false + command: mmsgCommands.query.layout stdout: SplitParser { onRead: function (line) { @@ -219,10 +228,11 @@ Item { } } - Process { - id: keyboardProcess - running: false - command: mmsgCommands.query.keyboard + // Process to query keyboard layout using mmsg -g -k + Process { + id: keyboardProcess + running: false + command: mmsgCommands.query.keyboard stdout: SplitParser { onRead: function (line) { @@ -248,10 +258,11 @@ Item { } } - Process { - id: outputsProcess - running: false - command: mmsgCommands.query.outputs + // Process to query output scales using mmsg -g -A + Process { + id: outputsProcess + running: false + command: mmsgCommands.query.outputs stdout: SplitParser { onRead: function (line) { @@ -283,10 +294,11 @@ Item { } } - Process { - id: monitorStateProcess - running: false - command: mmsgCommands.query.monitors + // Process to query monitor states using mmsg -g -o + Process { + id: monitorStateProcess + running: false + command: mmsgCommands.query.monitors stdout: SplitParser { onRead: function (line) { @@ -313,16 +325,17 @@ Item { } } - Process { - id: outputEnumProcess - running: false - command: ["mmsg", "-g", "-O"] + // Process to enumerate available outputs using mmsg -g -O + Process { + id: outputEnumProcess + running: false + command: ["mmsg", "-g", "-O"] stdout: SplitParser { onRead: function (line) { try { const trimmed = line.trim() - // Handle output enumeration format: "+ eDP-1" + const outputName = trimmed.replace(/^\+\s*/, '') if (outputName && !monitorCache[outputName]) { monitorCache[outputName] = { @@ -345,7 +358,8 @@ Item { } } - // Initialization + + // Initialize MangoService and establish connection to MangoWC function initialize() { if (initialized) { Logger.w("MangoService", "Already initialized") @@ -355,7 +369,6 @@ Item { try { Logger.i("MangoService", "Initializing MangoWC service...") - // Query monitor state first to establish selected monitor before parsing windows queryOutputEnum() queryMonitorState() eventStream.running = true @@ -373,36 +386,47 @@ Item { } } - // Workspace operations + + + + // Switch to a specific workspace/tag function switchToWorkspace(workspace) { try { const tagId = workspace.idx || workspace.id || defaultWorkspaceId const outputName = workspace.output || selectedMonitor || "" let command = [...mmsgCommands.action.tag] - if (outputName) { + // Only add -o parameter for multi-monitor setups + if (outputName && Object.keys(monitorCache).length > 1) { command.push("-o", outputName) } command.push(tagId.toString()) Quickshell.execDetached(command) - Logger.d("MangoService", `Switching to workspace ${tagId} on ${outputName || 'default output'}`) } catch (e) { Logger.e("MangoService", "Failed to switch workspace:", e) } } - // Window operations + + // Focus a specific window on its workspace function focusWindow(window) { try { if (window && window.output) { let command = [...mmsgCommands.action.view] - command.push("-o", window.output, window.workspaceId.toString()) + const isMultiMonitor = Object.keys(monitorCache).length > 1 + + if (isMultiMonitor) { + command.push("-o", window.output) + } + command.push(window.workspaceId.toString()) Quickshell.execDetached(command) Qt.callLater(() => { let focusCommand = [...mmsgCommands.action.focusMaster] - focusCommand.push("-o", window.output) + if (isMultiMonitor) { + focusCommand.push("-o", window.output) + } Quickshell.execDetached(focusCommand) }) } @@ -414,7 +438,7 @@ Item { function closeWindow(window) { try { const command = [...mmsgCommands.action.killClient] - if (selectedMonitor) { + if (selectedMonitor && Object.keys(monitorCache).length > 1) { command.push("-o", selectedMonitor) } Quickshell.execDetached(command) @@ -423,11 +447,11 @@ Item { } } - // MangoWC-specific operations + function toggleOverview() { try { const command = [...mmsgCommands.action.toggleOverview] - if (selectedMonitor) { + if (selectedMonitor && Object.keys(monitorCache).length > 1) { command.push("-o", selectedMonitor) } Quickshell.execDetached(command) @@ -454,7 +478,10 @@ Item { } } - // Data parsing + + // Parse workspace data from mmsg -g -t output + // Handles formats: tag details, tag masks, and binary states + // State bits: bit 0 = active/selected, bit 1 = urgent function parseWorkspaces(output) { const lines = output.trim().split('\n') const workspacesList = [] @@ -504,7 +531,7 @@ Item { const tagsMatch = trimmed.match(/^(\S+)\s+tags\s+(\d+)\s+(\d+)\s+(\d+)$/) if (tagsMatch) { const [, outputName, occ, seltags, urg] = tagsMatch - // Parse binary tag states for comprehensive workspace info + const occBits = occ.padStart(9, '0') const selBits = seltags.padStart(9, '0') const urgBits = urg.padStart(9, '0') @@ -559,18 +586,18 @@ Item { } } - function parseWindows(windowData) { + // Parse window data from mmsg -g -c output into window list + function parseWindows(windowData) { const windowsList = [] const newWindowCache = {} let newFocusedIndex = -1 for (const [outputName, data] of Object.entries(windowData)) { if (data.title || data.appId) { - // Windows from mmsg -g -o -c are the focused windows for their respective outputs - // A window is focused if it's from the currently selected monitor + const isFocused = (outputName === selectedMonitor) - // Get the active tag for this output + let activeTagId = defaultWorkspaceId for (const [key, tagData] of Object.entries(workspaceCache)) { if (tagData.output === outputName && tagData.isActive) { @@ -624,7 +651,8 @@ Item { } } - function handleLayoutChange(layoutSymbol) { + // Handle layout change events and update overview state + function handleLayoutChange(layoutSymbol) { const wasOverview = overviewActive const isOverview = (layoutSymbol === overviewLayoutSymbol) @@ -639,7 +667,8 @@ Item { } } - function updateDisplayScales() { + // Update display scales and notify CompositorService + function updateDisplayScales() { const scales = {} for (const [outputName, data] of Object.entries(monitorCache)) { scales[outputName] = { @@ -661,8 +690,9 @@ Item { displayScalesChanged() } - // Event handling - function handleEvent(eventLine) { + + // Handle real-time events from mmsg -w event stream and trigger updates + function handleEvent(eventLine) { const parts = eventLine.trim().split(/\s+/) if (parts.length < 2) return @@ -698,57 +728,67 @@ Item { } } - // Queries - function queryWorkspaces() { - workspacesProcess.running = true - } - function queryWindows() { - windowsProcess.running = true - } + // Start workspace query process + function queryWorkspaces() { + workspacesProcess.running = true + } - function queryLayout() { - layoutProcess.running = true - } + // Start window query process + function queryWindows() { + windowsProcess.running = true + } - function queryKeyboard() { - keyboardProcess.running = true - } + // Start layout query process + function queryLayout() { + layoutProcess.running = true + } - function queryOutputs() { - outputsProcess.running = true - } + // Start keyboard layout query process + function queryKeyboard() { + keyboardProcess.running = true + } - function queryDisplayScales() { - queryOutputs() - } + // Start output scales query process + function queryOutputs() { + outputsProcess.running = true + } - function queryOutputEnum() { - outputEnumProcess.running = true - } + // Query display scales (alias for queryOutputs) + function queryDisplayScales() { + queryOutputs() + } - function queryMonitorState() { - monitorStateProcess.running = true - } + // Start output enumeration process + function queryOutputEnum() { + outputEnumProcess.running = true + } - // Utilities - function safeUpdate() { - try { - queryWorkspaces() - queryWindows() - queryMonitorState() - } catch (e) { - Logger.e("MangoService", "Safe update failed:", e) - } - } + // Start monitor state query process + function queryMonitorState() { + monitorStateProcess.running = true + } - function getCurrentActiveTagId() { + + // Safely update all state by querying workspaces, windows, and monitor state + function safeUpdate() { + try { + queryWorkspaces() + queryWindows() + queryMonitorState() + } catch (e) { + Logger.e("MangoService", "Safe update failed:", e) + } + } + + // Get the ID of the currently active workspace/tag + function getCurrentActiveTagId() { for (const [key, tagData] of Object.entries(workspaceCache)) { if (tagData.isActive && tagData.output === selectedMonitor) { return tagData.id } } - // Fallback to any active tag if no selected monitor match + for (const [key, tagData] of Object.entries(workspaceCache)) { if (tagData.isActive) { return tagData.id From 4088c13eec49527b8997bf7cc72ac6c6dbcfaf1b Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 13:27:54 +0100 Subject: [PATCH 14/23] AudioService: preserve input value (fixes 0% volume after suspend... hopefully) autoformat --- Services/Media/AudioService.qml | 8 ++++---- Services/Theming/TemplateProcessor.qml | 2 +- Services/Theming/TemplateRegistry.qml | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Services/Media/AudioService.qml b/Services/Media/AudioService.qml index 60526eb3..9cb25a78 100644 --- a/Services/Media/AudioService.qml +++ b/Services/Media/AudioService.qml @@ -53,12 +53,12 @@ Singleton { var vol = source.audio.volume if (vol !== undefined && !isNaN(vol)) { root._inputVolume = vol - } else { - root._inputVolume = 0 } + // Don't reset to 0 if volume is undefined/NaN - preserve last known value root._inputMuted = !!source.audio.muted } else { - root._inputVolume = 0 + // Don't reset volume to 0 when source is unavailable - preserve last known value + // Only reset muted state root._inputMuted = true } } @@ -102,7 +102,7 @@ Singleton { function onVolumeChanged() { var vol = source?.audio?.volume if (vol === undefined || isNaN(vol)) { - root._inputVolume = 0 + // Don't reset to 0 if volume is undefined/NaN - preserve last known value return } // Only update if the value actually changed to prevent spurious signals diff --git a/Services/Theming/TemplateProcessor.qml b/Services/Theming/TemplateProcessor.qml index 9992bf1b..ba0400f1 100644 --- a/Services/Theming/TemplateProcessor.qml +++ b/Services/Theming/TemplateProcessor.qml @@ -235,7 +235,7 @@ Singleton { const templatePath = `${Quickshell.shellDir}/Assets/MatugenTemplates/${codeApp.input}` const outputPath = client.path.replace("~", homeDir) const outputDir = outputPath.substring(0, outputPath.lastIndexOf('/')) - + // Extract base config directory for checking var baseConfigDir = "" if (client.name === "code") { diff --git a/Services/Theming/TemplateRegistry.qml b/Services/Theming/TemplateRegistry.qml index 24da2974..2a9d2e6b 100644 --- a/Services/Theming/TemplateRegistry.qml +++ b/Services/Theming/TemplateRegistry.qml @@ -142,8 +142,7 @@ Singleton { "path": "~/.config/Vencord", "requiresThemesFolder": false }] - }, - { + }, { "id": "code", "name": "VSCode", "category": "applications", From 1573b5f128a5a3616b0d3c2c18d19a517a1783a9 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 13:31:41 +0100 Subject: [PATCH 15/23] OSD: fix initial input volume osd --- Modules/OSD/OSD.qml | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index d444bdca..e54dc5a8 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -39,6 +39,7 @@ Variants { readonly property real currentInputVolume: AudioService.inputVolume readonly property bool isInputMuted: AudioService.inputMuted property bool inputAudioInitialized: false + property real lastKnownInputVolume: -1 // Track last known volume to detect actual changes // Brightness properties property real lastUpdatedBrightness: 0 @@ -509,20 +510,36 @@ Variants { } function onInputVolumeChanged() { - if (!inputAudioInitialized) { - return - } if (!AudioService.hasInput) { return } - showOSD("inputVolume") + // Capture initial volume on first change to avoid showing OSD on startup + if (lastKnownInputVolume < 0) { + lastKnownInputVolume = AudioService.inputVolume + inputAudioInitialized = true + return + } + if (!inputAudioInitialized) { + return + } + // Only show OSD if volume actually changed from last known value + if (Math.abs(AudioService.inputVolume - lastKnownInputVolume) > 0.001) { + lastKnownInputVolume = AudioService.inputVolume + showOSD("inputVolume") + } } function onInputMutedChanged() { - if (!inputAudioInitialized) { + if (!AudioService.hasInput) { return } - if (!AudioService.hasInput) { + // Capture initial state on first change to avoid showing OSD on startup + if (lastKnownInputVolume < 0) { + lastKnownInputVolume = AudioService.inputVolume + inputAudioInitialized = true + return + } + if (!inputAudioInitialized) { return } showOSD("inputVolume") @@ -537,7 +554,7 @@ Variants { onTriggered: { volumeInitialized = true muteInitialized = true - inputAudioInitialized = true + // Input volume initializes on first change to avoid showing OSD on startup // Brightness initializes on first change to avoid showing OSD on startup connectBrightnessMonitors() } From f64a2fae4e637b4aa797bf42df3f3976480f73f8 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 13:54:59 +0100 Subject: [PATCH 16/23] OSD: fix initial output volume osd --- Modules/OSD/OSD.qml | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index e54dc5a8..b30122b2 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -34,6 +34,7 @@ Variants { readonly property bool isMuted: AudioService.muted property bool volumeInitialized: false property bool muteInitialized: false + property real lastKnownVolume: -1 // Track last known volume to detect actual changes // Input volume properties readonly property real currentInputVolume: AudioService.inputVolume @@ -498,15 +499,33 @@ Variants { target: AudioService function onVolumeChanged() { - if (volumeInitialized) { + // Capture initial volume on first change to avoid showing OSD on startup + if (lastKnownVolume < 0) { + lastKnownVolume = AudioService.volume + volumeInitialized = true + return + } + if (!volumeInitialized) { + return + } + // Only show OSD if volume actually changed from last known value + if (Math.abs(AudioService.volume - lastKnownVolume) > 0.001) { + lastKnownVolume = AudioService.volume showOSD("volume") } } function onMutedChanged() { - if (muteInitialized) { - showOSD("volume") + // Capture initial muted state on first change to avoid showing OSD on startup + if (lastKnownVolume < 0) { + lastKnownVolume = AudioService.volume + muteInitialized = true + return } + if (!muteInitialized) { + return + } + showOSD("volume") } function onInputVolumeChanged() { @@ -552,9 +571,7 @@ Variants { interval: 500 running: true onTriggered: { - volumeInitialized = true - muteInitialized = true - // Input volume initializes on first change to avoid showing OSD on startup + // Volume and input volume initialize on first change to avoid showing OSD on startup // Brightness initializes on first change to avoid showing OSD on startup connectBrightnessMonitors() } From 4129b4755940ca64666a391e833eec8c70941ff6 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 14:00:12 +0100 Subject: [PATCH 17/23] OSD: fix output OSD logic --- Modules/OSD/OSD.qml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index b30122b2..6b5938de 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -499,7 +499,7 @@ Variants { target: AudioService function onVolumeChanged() { - // Capture initial volume on first change to avoid showing OSD on startup + // If not initialized yet, capture initial volume silently (fallback if timer hasn't fired) if (lastKnownVolume < 0) { lastKnownVolume = AudioService.volume volumeInitialized = true @@ -516,7 +516,7 @@ Variants { } function onMutedChanged() { - // Capture initial muted state on first change to avoid showing OSD on startup + // If not initialized yet, capture initial state silently (fallback if timer hasn't fired) if (lastKnownVolume < 0) { lastKnownVolume = AudioService.volume muteInitialized = true @@ -532,7 +532,7 @@ Variants { if (!AudioService.hasInput) { return } - // Capture initial volume on first change to avoid showing OSD on startup + // If not initialized yet, capture initial volume silently (fallback if timer hasn't fired) if (lastKnownInputVolume < 0) { lastKnownInputVolume = AudioService.inputVolume inputAudioInitialized = true @@ -552,7 +552,7 @@ Variants { if (!AudioService.hasInput) { return } - // Capture initial state on first change to avoid showing OSD on startup + // If not initialized yet, capture initial state silently (fallback if timer hasn't fired) if (lastKnownInputVolume < 0) { lastKnownInputVolume = AudioService.inputVolume inputAudioInitialized = true @@ -571,7 +571,16 @@ Variants { interval: 500 running: true onTriggered: { - // Volume and input volume initialize on first change to avoid showing OSD on startup + // Capture initial volume values to avoid showing OSD on startup + if (lastKnownVolume < 0 && AudioService.volume !== undefined) { + lastKnownVolume = AudioService.volume + volumeInitialized = true + } + if (lastKnownInputVolume < 0 && AudioService.hasInput && AudioService.inputVolume !== undefined) { + lastKnownInputVolume = AudioService.inputVolume + inputAudioInitialized = true + } + muteInitialized = true // Brightness initializes on first change to avoid showing OSD on startup connectBrightnessMonitors() } From a32d999e46a9b1ca78cf7389cf35ba1961d34593 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 09:26:17 -0500 Subject: [PATCH 18/23] SmartPaneWindow: unload when not in use --- Modules/MainScreen/SmartPanel.qml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Modules/MainScreen/SmartPanel.qml b/Modules/MainScreen/SmartPanel.qml index 7574beeb..fda4c738 100644 --- a/Modules/MainScreen/SmartPanel.qml +++ b/Modules/MainScreen/SmartPanel.qml @@ -43,8 +43,8 @@ Item { // Support close with escape property bool closeWithEscape: true - // Track if window has been created (for lazy loading) - property bool windowCreated: false + // Track if window should be active (for lazy loading and cleanup) + property bool windowActive: false // Expose panel state (from content window) readonly property bool isPanelOpen: windowLoader.item ? windowLoader.item.isPanelOpen : false @@ -77,8 +77,8 @@ Item { // Public control functions function toggle(buttonItem, buttonName) { // Ensure window is created before toggling - if (!windowCreated) { - windowCreated = true + if (!root.windowActive) { + root.windowActive = true Qt.callLater(function () { if (windowLoader.item) { windowLoader.item.toggle(buttonItem, buttonName) @@ -91,8 +91,8 @@ Item { function open(buttonItem, buttonName) { // Ensure window is created before opening - if (!windowCreated) { - windowCreated = true + if (!root.windowActive) { + root.windowActive = true Qt.callLater(function () { if (windowLoader.item) { windowLoader.item.open(buttonItem, buttonName) @@ -143,10 +143,10 @@ Item { parent: root.parent } - // Lazy-load the content window (only created on first open) + // Lazy-load the content window (only created when open, destroyed when closed) Loader { id: windowLoader - active: root.windowCreated + active: root.windowActive sourceComponent: SmartPanelWindow { placeholder: panelPlaceholder panelContent: root.panelContent @@ -156,7 +156,13 @@ Item { // Forward signals onPanelOpened: root.opened() - onPanelClosed: root.closed() + onPanelClosed: { + root.closed() + // Destroy the window after close animation completes + Qt.callLater(function () { + root.windowActive = false + }) + } } } From 717ea441b09c704cc61bc5ed7f49bce3c9ac0b9a Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 14 Nov 2025 15:40:26 +0100 Subject: [PATCH 19/23] Settings: cleanup --- Assets/settings-default.json | 8 +----- Commons/Settings.qml | 47 ++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/Assets/settings-default.json b/Assets/settings-default.json index 320adebc..e8ca2ab8 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -297,13 +297,7 @@ "walker": false, "code": false, "spicetify": false, - "enableUserTemplates": false, - "discord_vesktop": false, - "discord_webcord": false, - "discord_armcord": false, - "discord_equibop": false, - "discord_lightcord": false, - "discord_dorion": false + "enableUserTemplates": false }, "nightLight": { "enabled": false, diff --git a/Commons/Settings.qml b/Commons/Settings.qml index d03d3a8b..56161540 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -438,17 +438,6 @@ Singleton { property bool code: false property bool spicetify: false property bool enableUserTemplates: false - - property bool code_code: false - property bool code_codium: false - - property bool discord_vesktop: false // To be deleted soon - property bool discord_webcord: false // To be deleted soon - property bool discord_armcord: false // To be deleted soon - property bool discord_equibop: false // To be deleted soon - property bool discord_lightcord: false // To be deleted soon - property bool discord_dorion: false // To be deleted soon - property bool discord_vencord: false // To be deleted soon } // night light @@ -658,22 +647,34 @@ Singleton { // 5th. Migrate Discord templates (version 20 → 21) // Consolidate individual discord_* properties into unified discord property if (adapter.settingsVersion < 21) { - var anyDiscordEnabled = false + // Read raw JSON file to access properties not in adapter schema + try { + var rawJson = settingsFileView.text() - // Check if any Discord client was enabled - const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion", "discord_vencord"] + if (rawJson) { + var parsed = JSON.parse(rawJson) + var anyDiscordEnabled = false - for (var i = 0; i < discordClients.length; i++) { - if (adapter.templates[discordClients[i]]) { - anyDiscordEnabled = true - break + // Check if any Discord client was enabled + const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion", "discord_vencord"] + + if (parsed.templates) { + for (var i = 0; i < discordClients.length; i++) { + if (parsed.templates[discordClients[i]]) { + anyDiscordEnabled = true + break + } + } + } + + // Set unified discord property + adapter.templates.discord = anyDiscordEnabled + + Logger.i("Settings", "Migrated Discord templates to unified 'discord' property (enabled:", anyDiscordEnabled + ")") } + } catch (error) { + Logger.w("Settings", "Failed to read raw JSON for Discord migration:", error) } - - // Set unified discord property - adapter.templates.discord = anyDiscordEnabled - - Logger.i("Settings", "Migrated Discord templates to unified 'discord' property (enabled:", anyDiscordEnabled + ")") } // ----------------- From 0eb82bce98faeebe5599fcd407c008599fcab61b Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 10:00:20 -0500 Subject: [PATCH 20/23] SmartPanel: Tighter sizing by using the minimum size. --- Modules/MainScreen/PanelPlaceholder.qml | 42 ++++ Modules/MainScreen/SmartPanelWindow.qml | 282 +++++++++++++----------- 2 files changed, 200 insertions(+), 124 deletions(-) diff --git a/Modules/MainScreen/PanelPlaceholder.qml b/Modules/MainScreen/PanelPlaceholder.qml index af50d4c4..3cd68d85 100644 --- a/Modules/MainScreen/PanelPlaceholder.qml +++ b/Modules/MainScreen/PanelPlaceholder.qml @@ -56,6 +56,48 @@ Item { // Expose panelBackground as panelItem for AllBackgrounds readonly property var panelItem: panelBackground + // Primary anchor edge for window positioning + readonly property string primaryAnchorEdge: { + if (effectivePanelAnchorTop) + return "top" + if (effectivePanelAnchorBottom) + return "bottom" + if (effectivePanelAnchorLeft) + return "left" + if (effectivePanelAnchorRight) + return "right" + return "top" + // default + } + + // Calculate window margins for content-sized panel windows + function getWindowMargins() { + if (!root.width || !root.height) + return { + "top": 0, + "bottom": 0, + "left": 0, + "right": 0 + } + + // Determine which edges are anchored (matching SmartPanelWindow logic) + var isPrimaryVertical = primaryAnchorEdge === "top" || primaryAnchorEdge === "bottom" + var isPrimaryHorizontal = primaryAnchorEdge === "left" || primaryAnchorEdge === "right" + + // Anchor the primary edge + opposite edges of the other axis + var useTop = effectivePanelAnchorTop || primaryAnchorEdge === "top" || isPrimaryHorizontal + var useBottom = effectivePanelAnchorBottom || primaryAnchorEdge === "bottom" || isPrimaryHorizontal + var useLeft = effectivePanelAnchorLeft || primaryAnchorEdge === "left" || isPrimaryVertical + var useRight = effectivePanelAnchorRight || primaryAnchorEdge === "right" || isPrimaryVertical + + return { + "top": useTop ? panelBackground.targetY : 0, + "bottom": useBottom ? (root.height - panelBackground.targetY - panelBackground.targetHeight) : 0, + "left": useLeft ? panelBackground.targetX : 0, + "right": useRight ? (root.width - panelBackground.targetX - panelBackground.targetWidth) : 0 + } + } + // Bar configuration readonly property string barPosition: Settings.data.bar.position readonly property bool barIsVertical: barPosition === "left" || barPosition === "right" diff --git a/Modules/MainScreen/SmartPanelWindow.qml b/Modules/MainScreen/SmartPanelWindow.qml index 40a52a90..2023abdb 100644 --- a/Modules/MainScreen/SmartPanelWindow.qml +++ b/Modules/MainScreen/SmartPanelWindow.qml @@ -48,6 +48,10 @@ PanelWindow { property bool closeWatchdogActive: false property bool openWatchdogActive: false + // Cached window size (only update when content size changes, not during animation) + property real cachedWindowWidth: 0 + property real cachedWindowHeight: 0 + // Signals signal panelOpened signal panelClosed @@ -57,18 +61,44 @@ PanelWindow { mask: null // No mask - content window is rectangular visible: isPanelOpen - // Wayland layer shell configuration - fullscreen window + // Wayland layer shell configuration - content-sized window WlrLayershell.layer: WlrLayer.Top WlrLayershell.namespace: "noctalia-panel-content-" + placeholder.panelName + "-" + (placeholder.screen?.name || "unknown") WlrLayershell.exclusionMode: ExclusionMode.Ignore WlrLayershell.keyboardFocus: !root.isPanelOpen ? WlrKeyboardFocus.None : (exclusiveKeyboard ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.OnDemand) - // Anchor to all edges to make fullscreen - anchors { - top: true - bottom: true - left: true - right: true + // Dynamic anchoring based on panel position + // For correct positioning with Wayland layer shell: + // - Anchor the primary edge (top/bottom/left/right) + // - Also anchor the opposite edge of the OTHER axis (both horizontal edges if panel is vertical, both vertical edges if panel is horizontal) + // This prevents unwanted centering and allows margins to position the panel correctly + readonly property bool isPrimaryVertical: placeholder.primaryAnchorEdge === "top" || placeholder.primaryAnchorEdge === "bottom" + readonly property bool isPrimaryHorizontal: placeholder.primaryAnchorEdge === "left" || placeholder.primaryAnchorEdge === "right" + + anchors.top: placeholder.effectivePanelAnchorTop || placeholder.primaryAnchorEdge === "top" || isPrimaryHorizontal + anchors.bottom: placeholder.effectivePanelAnchorBottom || placeholder.primaryAnchorEdge === "bottom" || isPrimaryHorizontal + anchors.left: placeholder.effectivePanelAnchorLeft || placeholder.primaryAnchorEdge === "left" || isPrimaryVertical + anchors.right: placeholder.effectivePanelAnchorRight || placeholder.primaryAnchorEdge === "right" || isPrimaryVertical + + // Size to content (cached to avoid resizing during animations) + implicitWidth: cachedWindowWidth + implicitHeight: cachedWindowHeight + + // Position via margins (calculated from target position, not animated position) + readonly property var windowMargins: placeholder.getWindowMargins() + margins.top: windowMargins.top + margins.bottom: windowMargins.bottom + margins.left: windowMargins.left + margins.right: windowMargins.right + + // Debug logging for positioning + Component.onCompleted: { + Logger.d("SmartPanelWindow", "Panel positioning:", placeholder.panelName) + Logger.d("SmartPanelWindow", " primaryAnchorEdge:", placeholder.primaryAnchorEdge) + Logger.d("SmartPanelWindow", " isPrimaryVertical:", isPrimaryVertical, "isPrimaryHorizontal:", isPrimaryHorizontal) + Logger.d("SmartPanelWindow", " anchors:", anchors.top, anchors.bottom, anchors.left, anchors.right) + Logger.d("SmartPanelWindow", " margins (TLBR):", windowMargins.top, windowMargins.left, windowMargins.bottom, windowMargins.right) + Logger.d("SmartPanelWindow", " size:", cachedWindowWidth, "x", cachedWindowHeight) } // Sync state to placeholder @@ -82,6 +112,19 @@ PanelWindow { placeholder.opacityFadeComplete = opacityFadeComplete } + // Update cached window size (only when target size changes) + function updateWindowSize() { + var targetWidth = placeholder.panelItem.targetWidth + var targetHeight = placeholder.panelItem.targetHeight + + // Only update if size actually changed + if (cachedWindowWidth !== targetWidth || cachedWindowHeight !== targetHeight) { + cachedWindowWidth = targetWidth + cachedWindowHeight = targetHeight + Logger.d("SmartPanelWindow", "Window size updated:", targetWidth, "x", targetHeight, placeholder.panelName) + } + } + // Panel control functions function toggle(buttonItem, buttonName) { if (!isPanelOpen) { @@ -110,6 +153,9 @@ PanelWindow { placeholder.useButtonPosition = false } + // Initialize cached window size + updateWindowSize() + // Set isPanelOpen to trigger content loading isPanelOpen = true @@ -164,12 +210,13 @@ PanelWindow { Logger.d("SmartPanelWindow", "Panel close finalized", placeholder.panelName) } - // Fullscreen container for click-to-close and content + // Content wrapper with opacity animation (fills content-sized window) Item { + id: contentWrapper anchors.fill: parent - focus: true // Enable keyboard event handling + focus: true - // Handle keyboard events directly via Keys handler + // Keyboard event handling Keys.onPressed: event => { Logger.d("SmartPanelWindow", "Key pressed:", event.key, "for panel:", placeholder.panelName) if (event.key === Qt.Key_Escape) { @@ -228,143 +275,120 @@ PanelWindow { } } - // Background MouseArea for click-to-close (behind content) - MouseArea { - anchors.fill: parent - enabled: root.isPanelOpen && !root.isClosing - acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton - onClicked: mouse => { - root.close() - mouse.accepted = true - } - z: 0 + // Opacity animation + opacity: { + if (isClosing) + return 0.0 + if (isPanelVisible && sizeAnimationComplete) + return 1.0 + return 0.0 } - // Content wrapper with opacity animation - Item { - id: contentWrapper - // Position at placeholder location within fullscreen window - x: placeholder.panelItem.x - y: placeholder.panelItem.y - width: placeholder.panelItem.width - height: placeholder.panelItem.height - z: 1 // Above click-to-close MouseArea + Behavior on opacity { + NumberAnimation { + id: opacityAnimation + duration: root.isClosing ? Style.animationFaster : Style.animationFast + easing.type: Easing.OutQuad - // Opacity animation - opacity: { - if (isClosing) - return 0.0 - if (isPanelVisible && sizeAnimationComplete) - return 1.0 - return 0.0 - } - - Behavior on opacity { - NumberAnimation { - id: opacityAnimation - duration: root.isClosing ? Style.animationFaster : Style.animationFast - easing.type: Easing.OutQuad - - onRunningChanged: { - // Safety: Zero-duration animation handling - if (!running && duration === 0) { - if (root.isClosing && contentWrapper.opacity === 0.0) { - root.opacityFadeComplete = true - var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight - if (shouldFinalizeNow) { - Logger.d("SmartPanelWindow", "Zero-duration opacity + no size animation - finalizing", placeholder.panelName) - Qt.callLater(root.finalizeClose) - } - } else if (root.isPanelVisible && contentWrapper.opacity === 1.0) { - root.openWatchdogActive = false - openWatchdogTimer.stop() - } - return - } - - // When opacity fade completes during close, trigger size animation - if (!running && root.isClosing && contentWrapper.opacity === 0.0) { + onRunningChanged: { + // Safety: Zero-duration animation handling + if (!running && duration === 0) { + if (root.isClosing && contentWrapper.opacity === 0.0) { root.opacityFadeComplete = true var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight if (shouldFinalizeNow) { - Logger.d("SmartPanelWindow", "No animation - finalizing immediately", placeholder.panelName) + Logger.d("SmartPanelWindow", "Zero-duration opacity + no size animation - finalizing", placeholder.panelName) Qt.callLater(root.finalizeClose) - } else { - Logger.d("SmartPanelWindow", "Animation will run - waiting for size animation", placeholder.panelName) } - } // When opacity fade completes during open, stop watchdog - else if (!running && root.isPanelVisible && contentWrapper.opacity === 1.0) { + } else if (root.isPanelVisible && contentWrapper.opacity === 1.0) { root.openWatchdogActive = false openWatchdogTimer.stop() } + return } - } - } - // Panel content loader - Loader { - id: contentLoader - active: isPanelOpen - anchors.fill: parent - sourceComponent: root.panelContent - - // When content finishes loading, trigger positioning and visibility - onLoaded: { - // Capture initial content-driven size if available - if (contentLoader.item) { - var hasWidthProp = contentLoader.item.hasOwnProperty('contentPreferredWidth') - var hasHeightProp = contentLoader.item.hasOwnProperty('contentPreferredHeight') - - if (hasWidthProp || hasHeightProp) { - var initialWidth = hasWidthProp ? contentLoader.item.contentPreferredWidth : 0 - var initialHeight = hasHeightProp ? contentLoader.item.contentPreferredHeight : 0 - placeholder.updateContentSize(initialWidth, initialHeight) - Logger.d("SmartPanelWindow", "Initial content size:", initialWidth, "x", initialHeight, placeholder.panelName) + // When opacity fade completes during close, trigger size animation + if (!running && root.isClosing && contentWrapper.opacity === 0.0) { + root.opacityFadeComplete = true + var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight + if (shouldFinalizeNow) { + Logger.d("SmartPanelWindow", "No animation - finalizing immediately", placeholder.panelName) + Qt.callLater(root.finalizeClose) + } else { + Logger.d("SmartPanelWindow", "Animation will run - waiting for size animation", placeholder.panelName) } + } // When opacity fade completes during open, stop watchdog + else if (!running && root.isPanelVisible && contentWrapper.opacity === 1.0) { + root.openWatchdogActive = false + openWatchdogTimer.stop() } - - // Calculate position in placeholder - placeholder.setPosition() - - // Make panel visible on the next frame - Qt.callLater(function () { - root.isPanelVisible = true - opacityTrigger.start() - - // Start open watchdog timer - root.openWatchdogActive = true - openWatchdogTimer.start() - - panelOpened() - }) } } + } - // MouseArea to prevent clicks on panel content from closing it - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton - onClicked: mouse => { - mouse.accepted = true // Eat the click to prevent propagation to background - } - z: -1 // Behind content but above background click-to-close - } + // Panel content loader + Loader { + id: contentLoader + active: isPanelOpen + anchors.fill: parent + sourceComponent: root.panelContent - // Watch for changes in content-driven sizes - Connections { - target: contentLoader.item - ignoreUnknownSignals: true + // When content finishes loading, trigger positioning and visibility + onLoaded: { + // Capture initial content-driven size if available + if (contentLoader.item) { + var hasWidthProp = contentLoader.item.hasOwnProperty('contentPreferredWidth') + var hasHeightProp = contentLoader.item.hasOwnProperty('contentPreferredHeight') - function onContentPreferredWidthChanged() { - if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { - placeholder.updateContentSize(contentLoader.item.contentPreferredWidth, placeholder.contentPreferredHeight) + if (hasWidthProp || hasHeightProp) { + var initialWidth = hasWidthProp ? contentLoader.item.contentPreferredWidth : 0 + var initialHeight = hasHeightProp ? contentLoader.item.contentPreferredHeight : 0 + placeholder.updateContentSize(initialWidth, initialHeight) + Logger.d("SmartPanelWindow", "Initial content size:", initialWidth, "x", initialHeight, placeholder.panelName) } } - function onContentPreferredHeightChanged() { - if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { - placeholder.updateContentSize(placeholder.contentPreferredWidth, contentLoader.item.contentPreferredHeight) - } + // Calculate position in placeholder + placeholder.setPosition() + + // Make panel visible on the next frame + Qt.callLater(function () { + root.isPanelVisible = true + opacityTrigger.start() + + // Start open watchdog timer + root.openWatchdogActive = true + openWatchdogTimer.start() + + panelOpened() + }) + } + } + + // MouseArea to prevent clicks on panel content from closing it + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + onClicked: mouse => { + mouse.accepted = true // Eat the click to prevent propagation to background + } + z: -1 // Behind content but above background click-to-close + } + + // Watch for changes in content-driven sizes + Connections { + target: contentLoader.item + ignoreUnknownSignals: true + + function onContentPreferredWidthChanged() { + if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { + placeholder.updateContentSize(contentLoader.item.contentPreferredWidth, placeholder.contentPreferredHeight) + } + } + + function onContentPreferredHeightChanged() { + if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) { + placeholder.updateContentSize(placeholder.contentPreferredWidth, contentLoader.item.contentPreferredHeight) } } } @@ -416,6 +440,16 @@ PanelWindow { Connections { target: placeholder.panelItem + function onTargetWidthChanged() { + // Update cached window size when target changes (not during animation) + root.updateWindowSize() + } + + function onTargetHeightChanged() { + // Update cached window size when target changes (not during animation) + root.updateWindowSize() + } + function onWidthChanged() { // When width shrinks to 0 during close and we're animating width, finalize if (root.isClosing && placeholder.panelItem.width === 0 && placeholder.panelItem.shouldAnimateWidth) { From a0dcd97aa637489bdfed2c39e06b037c80dae43c Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 10:11:57 -0500 Subject: [PATCH 21/23] TrayMenu: minimal fade-in animation when appearing. --- Modules/Bar/Extras/TrayMenu.qml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Modules/Bar/Extras/TrayMenu.qml b/Modules/Bar/Extras/TrayMenu.qml index f4e17e78..e0831f7a 100644 --- a/Modules/Bar/Extras/TrayMenu.qml +++ b/Modules/Bar/Extras/TrayMenu.qml @@ -122,6 +122,16 @@ PopupWindow { border.color: Color.mOutline border.width: Math.max(1, Style.borderS) radius: Style.radiusM + + // Fade-in animation + opacity: root.visible ? 1.0 : 0.0 + + Behavior on opacity { + NumberAnimation { + duration: Style.animationNormal + easing.type: Easing.OutQuad + } + } } Flickable { @@ -131,6 +141,16 @@ PopupWindow { contentHeight: columnLayout.implicitHeight interactive: true + // Fade-in animation + opacity: root.visible ? 1.0 : 0.0 + + Behavior on opacity { + NumberAnimation { + duration: Style.animationNormal + easing.type: Easing.OutQuad + } + } + // Use a ColumnLayout to handle menu item arrangement ColumnLayout { id: columnLayout From 73269047ca580b638edccad7c7ec5d8d43db4558 Mon Sep 17 00:00:00 2001 From: atheeq-rhxn Date: Fri, 14 Nov 2025 20:48:46 +0530 Subject: [PATCH 22/23] fix: show empty workspaces when hideUnoccupied enabled --- Services/Compositor/MangoService.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Services/Compositor/MangoService.qml b/Services/Compositor/MangoService.qml index 23a9fc84..2ad63e0f 100644 --- a/Services/Compositor/MangoService.qml +++ b/Services/Compositor/MangoService.qml @@ -512,7 +512,7 @@ Item { name: tagId.toString(), output: outputName, isActive: isActive, - isFocused: isFocused && (outputName === selectedMonitor), + isFocused: isFocused || (isActive && (outputName === selectedMonitor)), isUrgent: isUrgent, isOccupied: isOccupied, clients: parseInt(clients) From 7bb27b6c29788c3b27ff4788a70a2b148ba8b94e Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 13:51:51 -0500 Subject: [PATCH 23/23] Settings: remove double sessionMenu tab --- Modules/Panels/Settings/SettingsPanel.qml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Modules/Panels/Settings/SettingsPanel.qml b/Modules/Panels/Settings/SettingsPanel.qml index c0dda187..62878b65 100644 --- a/Modules/Panels/Settings/SettingsPanel.qml +++ b/Modules/Panels/Settings/SettingsPanel.qml @@ -259,11 +259,6 @@ SmartPanel { "label": "settings.screen-recorder.title", "icon": "settings-screen-recorder", "source": screenRecorderTab - }, { - "id": SettingsPanel.Tab.SessionMenu, - "label": "settings.session-menu.title", - "icon": "settings-session-menu", - "source": sessionMenuTab }, // { // "id": SettingsPanel.Tab.SystemMonitor, // "label": "settings.system-monitor.title",