Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DBus interface to expose some actions/functions of PaperWM #738

Open
Lythenas opened this issue Dec 21, 2023 · 7 comments
Open

Add DBus interface to expose some actions/functions of PaperWM #738

Lythenas opened this issue Dec 21, 2023 · 7 comments
Labels
enhancement Adds a new feature or extends scope

Comments

@Lythenas
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
It is not possible to trigger PaperWM actions or call PaperWM functions using custom scripts or keybindings. This was made even less possible in Gnome 45 because we don't support a user.js anymore.

This would be useful for users to more easily extend the functionality of PaperWM.

This came up in at least two other issues: #727, #730

Describe the solution you'd like
Add a DBus interface for (most) of the PaperWM functionality.

The scope of this should be discussed. Since all changes to the DBus interface would technically be a breaking changes for users. We should define clearly what to expose. I propose to start with the actions available as keybindings (since they are simple functions without arugments, etc.) and later expand on that.

Some way to dump or inspect the PaperWM state would also be useful for debugging or troubleshooting. We could later also add "monitor" functionality that can be used to trace "events" in PaperWM in more detail.

Exposing the entire "internal" PaperWM API might come with a lot of boilerplate (not sure if that could be generated) and I'm not sure if we really want to do that.

Gnome also has a DBus endpoint to run arbitrary JS code. We could provide something similar to access the internal PaperWM API. This might be easier than exposing everything manually. The Gnome DBus endpoint for this is only enabled in unsafe mode (which you can turn on in looking glass via global.context.unsafe_mode = true).

Describe alternatives you've considered

  1. expose the PaperWM extension as a global variable in Looking Glass (does not really help with scripting or custom keybindings, only useful for debugging)
  2. implement some other custom way to interface with PaperWM

Additional context

@Lythenas Lythenas added the enhancement Adds a new feature or extends scope label Dec 21, 2023
@Lythenas
Copy link
Collaborator Author

@jtaala are there any guidelines about using DBus for EGO that we need to consider?

@KETHERCORTEX
Copy link

This would be useful for users to more easily extend the functionality of PaperWM.

Not only for that. It would greatly improve the accessibility and usability in multiple ways. Right now the functionality is available only through keyboard shortcuts allowed by GNOME for extensions. There are multiple cases where the possibility to call a function externally will be benefitial:

  1. Usage of alternative input devices or apps. It includes different remotes, gamepads, custom action keys, custom action panels, or more exotic things like voice control, mouse gestures or even wilder stuff like menu/launcher application displayed on a phone with launched X server.
  2. Binding actions to key combinations through alternative means. For example, even GNOME Settings app, despite its limitations, allows binding a command to Mail, Web Browser, Pause/Break or F1-F12 keys on my keyboard. Not "something + key", but just a single key from the ones I listed. Meanwhile PaperWM's extension settings dialog doesn't allow doing that, limiting shortcuts to "modifier(s) + key" pattern.
  3. Pointer-centric usage. It includes touchscreens, graphics tablets or cases when mouse is just more convenient to grab and click. It will make possible to add a few simple launcher icons on a visible panel (like the one from Dash to Dock extension) to use when needed.
  4. (I may misremember the details for this one) In Wayland apps may be limited with "broadcasting keypresses". For example, there are cases when password manager can't input passwords in another window. So the ability to call a command will eliminate such a problem for software reading inputs from a device and translating them into actions.

@bilboquet
Copy link
Collaborator

That's a very exciting evolution.
Thanks for all that.

@jtaala
Copy link
Collaborator

jtaala commented Dec 22, 2023

Well, don't thank us yet - we still need to find someone to implement this...

For me, this would be on the list but not a high priority. Would definitely accept a PR for this though for anyone that wants to give this a go.

@jtaala
Copy link
Collaborator

jtaala commented Dec 22, 2023

@jtaala are there any guidelines about using DBus for EGO that we need to consider?

Not that I'm aware of. Only thing on extension guide is an intro to dbus and how to interact via dbus in extensions. No specific guidelines re dbus - there certainly was no issue (raised or questions asked) with our async dbus connector #577.

@Lythenas
Copy link
Collaborator Author

I would be generally interested in implementing this. Especially this part to help debugging because sometimes it is really not clear to me what exact steps PaperWM takes^^

Some way to dump or inspect the PaperWM state would also be useful for debugging or troubleshooting.

If I get time over Christmas I will try to implement a proof of concept. This might also help with #707 because I can't figure out why it triggers sometimes and sometimes not.

@Lythenas
Copy link
Collaborator Author

I have been experimenting a bit with this and have some basics working.

If global.context.unsafe_mode = true Gnome itself also exposes a DBus interface to evaluate arbitrary JS code. If we expose paperwm somewhere (e.g. we could do global.paperwm = the imports module) then that would allow doing almost everything. But as far as I can tell there is no way to set global.context.unsafe_mode = true except in looking glass (not through dconf,DBus, terminal or other config). But I also doubt that EGO would accept an alternate interface from us that allow executing arbitrary JS code. So beyond exposing PaperWM in global.paperwm (or similar) we probably can't do anything.

Besides that exposing functions manually is mostly straight forward but requires some boilerplate. I will look into a way to generate some of the DBus interfaces from our existing actions/keybindings. I.e. simple function calls without arguments (like what keybindings would do).

@Lythenas Lythenas mentioned this issue Feb 3, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds a new feature or extends scope
Projects
None yet
Development

No branches or pull requests

4 participants