Retrieve the currently right-clicked application in task manager

Is it possible to retrieve the right-clicked application in the task manager (for instance the pid, which I would use to create a dbus address)?
In my case, I would like to add actions to kate, but I am struggling to understand if that’s even possible.
I am familiar with that ~/.local/share/kservices5/ServiceMenus way, but I am not sure it might work that way.

1 Like