-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Create exwm-minor-mode
#868
base: master
Are you sure you want to change the base?
Conversation
Interesting. What is the rationalle behind this change? |
* exwm.el (exwm-minor-mode): New function. (exwm-enable, exwm-disable, exwm-init, exwm-exit): Deprecate in favor of `exwm-minor-mode'. (exwm--init): Rework to signal errors and cleanup in case of errors. (exwm--exit): More thorough cleanup. (exwm--cleanup): New function. (exwm--on-SelectionClear, exwm--confirm-kill-emacs): : Use `exwm--exit'. (exwm--terminal-x-p, exwm--find-any-x-frame) (exwm--init-on-window-setup-hook) (exwm--init-on-after-make-frame, exwm--cleanup): New functions. (exwm--wmsn-acquire): Signal error instead of using `user-error'.
912ecf5
to
a824aad
Compare
A minor mode is some feature that can be enabled and disabled. When enabled, it adds to or alters Emacs' capabilities, binds commands to some keys, shows some menus, etc. This fits EXWM functionality. Indeed, EXWM does all of this already, some of it in some peculiar ways. I'd like to make EXWM less peculiar (where possible), and this is a small step in that direction. There are no functionality changes, though some of the entrypoints (e.g. |
Can exwm as minor mode restore the previous window manager (if there was one)? |
That's generally not possible to do reliably. Many window managers are components of larger systems. |
It seems to be possible with xprop: https://askubuntu.com/a/1153698/329876
I’m asking because if I were to disable the minor-mode, I would not have a wm and that could cause Emacs to lose keyboard focus, leaving me without an ability to start another wm. Would it maybe be possible to do this with a fallback? If there was a wm before (exwm already detects that) then use the detected wm and if that fails (or the previous one cannot be detected) use a fallback wm? |
That returns the window manager's name but that's not enough to restore it. EXWM would need to know how to start the window manager and most window managers expect to run within a specific environment (e.g., managed by a session manager). |
Aren’t you usually already in that environment if exwm replaced the window manager? (just starting the window manager by hand usually worked for me, if I could find out which one was used by the session manager) |
Not necessarily.
- There's no reliable way to get the exact command that started the
window manager. It may be possible to get the PID of the window manager
then get the command from /proc, but that's kind of hacky and isn't
guaranteed to work.
- There's no reason a window manager can't have multiple processes.
I.e., the window manager process (from the perspective of Xorg) may not
actually be the "root" window manager process.
In practice, it may be possible to "restart" most "simple" window
managers. But I wouldn't expect it to be reliable enough to actually
build it in as a feature. I.e., if you replace a running Gnome window
manager with EXWM, there's no way EXWM would be able to put everything
back together.
|
Indeed, we could read the previous WM name before replacing it. I see the following challenges:
@ArneBab, would you be willing to work on this? I have very limited time, but would try to support you as possible. Please note that EXWM is part of GNU Emacs, so copyright assignment to the FSF would be needed. At last, I'd like to point out that restarting the previous WM is orthogonal to this particular change: although a minor mode leads itself to being activated and deactivated, Thank you. |
@medranocalvo I have no problem with copyright assignment to GNU — can you send me the papers? (do you have my email address?) This would make temporary exwm sessions more practical for me, so I would try to work on this (I likely won’t be fast, though, already too many projects on my plate). My experience is that just starting another wm worked well enough for me. The hardest challenge was to remember or find the name of the window manager (or just start another one, they may not be fully interchangeable, but just having any window manager already makes most desktop environments work again). |
Please, have a look at https://www.gnu.org/software/emacs/manual/html_node/emacs/Copyright-Assignment.html.
Tell me about time! I suggest you to open a PR with whatever first questions you might have. Have a look at
I tested various WMs while developing replace support (#380). For me their |
I just remembered that I had issues using EXWM replace functionality under GNOME last time I tried. When replacing the WM, I got a gigantic dialog whose only button would kill the session. What I remember from my (non) understanding at the time is that unless the WM registers with the login manager (?) it will consider the session idle (?) and terminate it. @Stebalien, is something like that what you had in mind? See https://man.archlinux.org/man/systemd-logind.service.8.en. |
That specific case is probably not an issue in this case if EXWM has
already successfully replaced an existing window manager.
I was more concerned with the fact that restoring a window manager isn't
always as simple as starting a process. E.g.:
- In my case, I run Emacs within a systemd user service so any window
managers I automatically spawn would die with emacs.
- Window managers may expect other components to be started alongside
them and said components may have shutdown when the window manager was
killed.
|
@Stebalien: thank you for your explanation. You are right: we won't be able to recover to custom setups. I'm also not sure whether we will be able to recover to complex standard setups, say GNOME4 with the login manager. The objective is, as far as I'm concerned, making it seamless to try out EXWM (@ArneBab has a different but compatible objective, if I understood correctly). @ArneBab: the following let's us recover XFCE4 after replacing it with EXWM. (call-process "xfwm4" nil 0 nil "--replace") Seems to continue working after killing Emacs after replacing EXWM with XFWM4. |
@medranocalvo This would already make it much more painless to try exwm. Currently when I quit Emacs, I have to somehow start another window manager, which often means closing window after window until I finally get keyboard focus on a shell. Getting rid of that would go a long way to make a quick test more enjoyable. |
I want to note that I find the restarting the replaced WM is important feature for trying out EXWM. I'll open a ticket on @emacs-exwm and will try to work on it (no promises). |
Thanks, I like this change. I wonder if we should also change the scheme for the extensions, introducing |
With this change I intend to convert EXWM into a global minor mode.
Please check out and test.
Next steps would be e.g. creating a menu for the minor mode where workspaces can be managed (at the moment the menu is only available when an EXWM-mode buffer is current). Please discuss further ideas.