Skip to content

feat(tray): add IPC action to open tray menus#2701

Open
lankong0522 wants to merge 1 commit into
AvengeMedia:masterfrom
lankong0522:feat/tray-menu-ipc
Open

feat(tray): add IPC action to open tray menus#2701
lankong0522 wants to merge 1 commit into
AvengeMedia:masterfrom
lankong0522:feat/tray-menu-ipc

Conversation

@lankong0522

Copy link
Copy Markdown

Summary

This adds a new tray IPC action:

dms ipc call tray menu <id>

The new action opens the menu for a system tray item using the same item lookup behavior as the existing tray IPC actions.

Implementation

  • Adds an openTrayMenuRequested signal to TrayMenuManager.
  • Adds a menu(itemId) function to the tray IPC handler.
  • Handles the actual menu opening in SystemTrayBar by reusing the existing showForTrayItem() path.

The IPC layer only requests the menu to be opened. It does not attempt to render or display tray menus directly.

Motivation

This makes it possible to open tray item menus from compositor keybindings, for example from niri shortcuts, without manually clicking the tray item in the bar.

Tested

Tested with a separate Quickshell test config:

qs -c dms-test
qs ipc -c dms-test call tray list
qs ipc -c dms-test call tray menu "wechat"
qs ipc -c dms-test call tray menu "Fcitx"
qs ipc -c dms-test call tray menu "nm-applet"

@Spoch-dev

This comment was marked as spam.


signal openTrayMenuRequested(string itemId)

function requestOpenTrayMenu(itemId) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this function, its useless

target: TrayMenuManager

function onOpenTrayMenuRequested(itemId) {
const item = root.allTrayItems.find(trayItem => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move findTrayItem to TrayMenuManager instead of duplicating the logic

if (!item || !item.hasMenu)
return;

TrayMenuManager.closeAllMenus();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, already handled by showForTrayItem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants