EXWM contribution layer for Spacemacs
Table of Contents
- EXWM contribution layer for Spacemacs
- Window behaviour regarding char and line mode
- Known Limitations
Fork Note: This layer is based on CestDiego’s PR from https://github.com/syl20bnr/spacemacs/pull/3321.
The time has arrived when one can finally use Emacs as a Window Manager, long ago the concepts of windows and frames made so much sense when one was working in a TTY, and basically that’s all the window management you got. In these modern times though, it sounds silly to have those names. But not Anymore!
Thanks to @ch11ng and his EXWM project we can now use Emacs as our window manager, and all those windows that didn’t make sense before, now can not only hold buffers, but X Windows, that means that you can spawn a Browser Window, or your music player, or anything.
I urge you to read the EXWM Wiki for a more in depth explanation and if you can contribute, please do so! The purpose of me making this layer is that I find it awesome and having nice defaults would make more people dive into it and the project would receive more attention and contributions which will only make it more awesome, so if you try it and like it, share it!
This is how it looks like:
To use this contribution,
- place this repository in one of Spacemacs’ layer directories (~/.emacs.d/private/local/exwm, ~/.spacemacs.d/private/exwm, or ~/.spacemacs.d/layers/exwm)
- add an entry
exwmfor the layer in your
~/.spacemacs, optionally set some configuration variables:
;; (setq-default dotspacemacs-configuration-layers ... (exwm :variables exwm-enable-systray t exwm-autostart-xdg-applications t exwm-locking-command "i3lock -n" exwm-install-logind-lock-handler t exwm-terminal-command "st" exwm-custom-init (lambda() (exwm/autostart-process "Dunst OSD" "dunst"))) ;; )
Note about Display Managers
This is most common among Ubuntu and derivative users:
LightDM, GDM, and other Display managers that need a session file will need you
to copy the desktop file I bundled with this layer to
/usr/local/xsessions/exwm.desktop, that’s what I used on my Ubuntu box, but
make sure the exwm-start script is in your PATH, you can put it in
/usr/local/bin/exwm-start and that should be enough, next time you log out,
select the EXWM session instead of the Ubuntu one and you should be alright.
Not having Display Managers
If you use Arch, Gentoo, or any other Linux, most probably you’ll start your
configurations via a
.xinitrc file, just append
exwm-start to the end of
that file and you should be fine. I do recommend to check the EXWM Wiki for more
If you are an OSX user, please report back on whether this works with xQuartz, always back up your data before attempting to try stuff like this.
Configurable support for optional EXWM features:
- System Tray
The following features are preconfigured/provided on top of EXWM:
- EXWM buffer names are prefixed with a configurable prefix (default:
X:), to aid buffer selection in ivy/helm.
- Limited Support for XDG autostart applications in
~/.config/autostart~(does not support any advanced
.desktopfile entries, does not take into account system-wide
- Session locking with specified lock command
- Support for D-Bus based locking (e.g.
Normal State Bindings
|Switch from normal state to insert state, (similar to EXWM char mode)|
Major Mode Bindings
These bindings are accessible via the major mode leader keys when EXWM buffers
are focused, but only in normal state. This means that you usually have to get
out of insert state with
|Toggle floating/tiling for current window|
|Move current window to different workspace|
As other window managers the
s or Super key (Windows Key) is the one that
is the prefix to every action. We’ll use a lot of
s. These commands work in
both normal state and insert state.
|Spacemacs Leader Key (in insert state)|
|Switch to workspace [0 … 9]|
|Switch to previous/next workspace|
|Switch to last workspace|
|Workspace Switch Menu (kinda like micro-state)|
|Switch to normal state, cancel fullscreen|
|Undo, Redo window configurations|
|Select and switch to buffer|
|Close current buffer|
|Switch to left,lower,upper,right window|
|Move window to far left,down,lower,upper,right|
|Resizing (try them, it’s too hard to explain)|
|Toggle maximized buffer|
|Toggle exwm debug mode (for development)|
Since running programs is one of the more common task, some explicit support is
provided for that via the leader key
For these commands as well as for
s-r the working directory is set to the
user-home-directory for the started process.
|Ask for program to run in separate window below current window|
|Ask for program to run in separate window to the right of current window.|
This layer overrides the leader bindings on
SPC F, which are tricky with EXWM
anyways, and replaces them with the following bindings.
|Reset state of current window (exwm-reset)|
|Hide floating window|
|Prompt for workspace and switch to it|
|Add new workspace|
|Delete current workspace|
|Move Workspace to different position|
|Interchange position of two workspaces|
|Detach Minibuffer (for autohide enabled)|
|Attach Minibuffer (for autohide enabled)|
Window behaviour regarding char and line mode
In stock Emacs, EXWM uses char mode and line mode to distinguish between using the keyboard to control an application vs. using the keyboard to control the application’s buffer. Since Spacemacs pursues a different concept regarding keybindings SpacemacsOS handles this differently:
- EXWM buffers are used in line mode, all local key bindings are removed per default. This corresponds to Spacemacs insert state.
- The command
s-ESC) enters EXWM’s input passthrough mode, meaning that all key-presses are sent to Spacemacs, and not the application. This corresponds to Spacemacs normal state.
(3rd party research welcome…)
s-SPC mdoes not work for accessing major mode bindings
- When clicking into a buffer in normal state to press something, it has to be clicked twice, because the first click only gets you into insert state
- In some cases, the Emacs GUI becomes completely unresponsive if an X window
was opened by Emacs’ foreground command loop, e.g. when emacs starts an waits
for the return of an interactive graphical password entry dialog. To get it
to respond again, switch to a text console and send the SIGUSR2 signal
pkill -USR2 emacs).
- Under certain conditions, an EXWM buffer may end up in a state where Emacs
wants to insert into the underlying buffer, and pressing
idoes not get you into insert state. If that happens, use
s-ESCto get to line mode/normal state, where you should be able to use
ito to get into insert state again.