diff --git a/quickshell/Common/TrayMenuManager.qml b/quickshell/Common/TrayMenuManager.qml index 560d75712..eed7dec04 100644 --- a/quickshell/Common/TrayMenuManager.qml +++ b/quickshell/Common/TrayMenuManager.qml @@ -8,6 +8,12 @@ Singleton { property var activeTrayMenus: ({}) + signal openTrayMenuRequested(string itemId) + + function requestOpenTrayMenu(itemId) { + openTrayMenuRequested(itemId) + } + function registerMenu(screenName, menu) { if (!screenName || !menu) return const newMenus = Object.assign({}, activeTrayMenus) diff --git a/quickshell/DMSShellIPC.qml b/quickshell/DMSShellIPC.qml index 9ac839dab..fc58df7fc 100644 --- a/quickshell/DMSShellIPC.qml +++ b/quickshell/DMSShellIPC.qml @@ -1976,6 +1976,18 @@ Item { return `SUCCESS: Activated ${itemId}`; } + function menu(itemId: string): string { + const item = findTrayItem(itemId); + if (!item) + return `ERROR: Tray item not found: ${itemId}`; + + if (!item.hasMenu) + return `ERROR: Tray item has no menu: ${itemId}`; + + TrayMenuManager.requestOpenTrayMenu(itemId); + return `SUCCESS: Requested menu ${itemId}`; + } + function status(itemId: string): string { const item = findTrayItem(itemId); if (!item) diff --git a/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml b/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml index 52e37e9d1..3839dc6ff 100644 --- a/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml +++ b/quickshell/Modules/DankBar/Widgets/SystemTrayBar.qml @@ -84,6 +84,25 @@ BasePill { root.showForTrayItem(trayItem, anchorItem, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis); } + Connections { + target: TrayMenuManager + + function onOpenTrayMenuRequested(itemId) { + const item = root.allTrayItems.find(trayItem => { + const id = trayItem?.id || ""; + const tooltipTitle = trayItem?.tooltipTitle || ""; + const fullKey = (!tooltipTitle || tooltipTitle === id) ? id : `${id}::${tooltipTitle}`; + return itemId === id || itemId === fullKey; + }); + + if (!item || !item.hasMenu) + return; + + TrayMenuManager.closeAllMenus(); + root.showForTrayItem(item, root, parentScreen, root.isAtBottom, root.isVerticalOrientation, root.axis); + } + } + function openInlineTrayContextMenu(trayItem, areaItem, mouse, anchorItem) { if (!trayItem) { return;