reddit / emacs

Integrating the window manager and emacs

kamui78 · 2022-05-16 10:22
I have been using EXWM for a while now but it is not a smooth experience. Among issues I experience often are the constant fight with dbus and poor support for resizing windows. Another issue is that when emacs is stuck the session is frozen. Also, no support for dbus-anthy and I need it for Japanese input. I do not have these issues in i3 but at the same time I now understand how nice is have emacs at your fingertips all the time. I also use i3 and rofi but the more I use EXWM the more I feel that having two sets of keybindings in i3 for managing the emacs buffers and xorg clients is a pain in the butt. I was thinking that maybe it would be good idea to integrate emacs and i3 by finding a way to implement the following concepts: 1. Having a rofi like window but it is actually the execute-extended-command from emacs., The window can be dismissed, used to compute elisp, search a file and open a buffer etc. Basically a mini window with all the emacs goodies. It is like the entry point for interacting with the emacs+i3 shell/window manager. 2. Leave the management of all the windows to the window manager but integrate the two. All the emacs buffers are opened as separated xorg client instances of emacsclients. Basically each emacs buffer is a separated xorg window. Since all windows are running emacsclient there is one session. 3. Make most of the functions in elisp. But assign all the functions that might block the session to i3 and other programs that do not depend on emacs. How would you implement this and would it be possible? Please feel free to suggest ideas and suggestions. I have no idea how to implement this so pointers are very much welcome. My idea is to make something like EXWM but without relying completely on emacs for all the functions, especially the ones which might block the session. I already have a heavily customized i3 session with rofi and a bunch of bash scripts that work well. It is just that emacs and the rest of the my system are somehow quite disjoint.
_viz_ · 2022-05-16 11:06
You can achieve (1) if you used a minibuffer-only frame. Drew writes a lot about it in an article(?) called One on One Emacs over at emacswiki: https://www.emacswiki.org/emacs/OneOnOneEmacs. The pain points of managing the *Completions* buffer should be relieved for you if use a completion UI that uses the minibuffer like ivy, icomplete, etc. Once you do this, you can hide the miniwindow by setting default-frame-alist to an appropriate value. To quickly run commands, you can ofc simply say M-x or w/e but you can also bind them in minibuffer-inactive-mode-map IIRC. For (2), there's frames only mode that is commonly used by tiling wm users. I think this is the one: https://github.com/davidshepherd7/frames-only-mode No idea what you mean by (3). ------ You can also completely replace rofi with a minibuffer-only frame. AFAIK, neeasade (https://github.com/neeasade) does/did this. This plays out in two ways: you replace your shell scripts with elisp ones, or just replace rofi with Emacs. I think going with the former would be better since now you have Emacs at its fullest in your hand so you can go crazy with embark and whatnot. [ I tried this a while back, but just gave up. :P ]
aancel · 2022-05-16 12:08
There was an interesting post quite recently about shared keybindings between emacs and i3. I've implemented a similar workflow and it works great ! [https://www.reddit.com/r/emacs/comments/q2q4z5/getting\_a\_consistent\_set\_of\_keybindings\_between/](https://www.reddit.com/r/emacs/comments/q2q4z5/getting_a_consistent_set_of_keybindings_between/) Maybe it can help you in what you aim at doing !
kamui78 · 2022-05-16 12:26
Thank you very much for your post. It is extremely useful. By point 3 I meant that I will need to strike the balance on what for to rely on emacs and elisp and what for to rely on other programs such as i3 for managing the xorg clients and emacs frames.
karthink · 2022-05-16 19:00
I use this to integrate emacs with i3. I tweaked it a bit at the start, it's been seamless since.
arthurno1 · 2022-05-17 07:54
I have actually never used i3 myself, but unless it has an option to listen for commands from a socket, you might be better served by [bspwm](https://github.com/baskerville/bspwm). It is also a tiling manager, probably does not have all or same capabilities as i3, however, option to listen for commands on a socket makes it a very good candidate for integration with Emacs. Since Emacs can easily read/write to sockets, you might write a client in elisp and use it from your Emacs. Also, the partitioning algorithm used to manage windows, *in manual mode*, seems to be very similar to the way Emacs splits its windows, so it might be relatively easy to map the eventual elisp functions you write to bspwm. Another option would be to use a tool like wmctrl or xdotool and write small functions in elisp to send commands to select windows and place where you want them, to put them back/front in stack etc. Seems like a more tedious, and probably much more work, than using bspwm though. You can definitely replace Rofi with Emacs, and even some other shell stuff.
_viz_ · 2022-05-17 09:23
Another option would be x11fs.
arthurno1 · 2022-05-17 12:32
Cool, never heard of [x11fs](https://github.com/sdhand/x11fs) before. Yes, it seems like it is done exactly for a purpose like asked by OP.
kamui78 · 2022-05-17 14:02
Thank you very much. Will look into bspwm.
j0nsky · 2022-05-17 20:16
Thank you so much. I installed frames-only-mode and it works fine in dwm so far.