Exwm is a lightweight tiling window manager for Linux that turns Emacs into a complete graphical environment. In this article, I will go through the benefits of using Exwm, install it on Ubuntu 24.10, and show some of what you can do with this fascinating window manager.
Content
- Why Use Exwm As Your Window Manager
- Installing Exwm in Emacs
- Using Exwm for the First Time
- Running and Managing Programs in Exwm
- Configuring and Customizing Exwm
- Creating New Keyboard Shortcuts in Exwm
Why Use Exwm As Your Window Manager
One of the biggest selling points of Exwm is that it can integrate other apps into your existing Emacs workflow. This allows you to use what you already know about Emacs buffers and apply it to your other apps, making you more efficient in the long run.
In addition, Exwm also reduces the amount of config files present on a desktop setup. With it, your .emacs file acts as the config for your text editor and your window manager. This makes it attractive to users who want to reduce the clutter they manage on their system.
Lastly, Exwm is incredibly lean and quick. In my experience, loading the window manager from a cold boot takes a few seconds, and running it for a whole day only consumes over 500 MB of RAM.
On a side note: looking for a more modern window manager? Check out our guide on setting up and running Hyprland in Linux.
Installing Exwm in Emacs
The first step in installing Exwm in Linux is to make sure that you have both Emacs and its dependencies on your system. To do that, run the following command:
sudo apt install emacs dbus gnome-settings-daemon
Open your Emacs client, press Alt + X, then type “package-install” to bring up the editors installation prompt.
Type “exwm” on the prompt, then press Enter to install the window manager inside Emacs.
Press Ctrl + X, then Ctrl + F to bring up the file buffer, type “~/.emacs” on the prompt, then press Enter.
Paste the following block of code inside your new .emacs file. This is a modified version of the default config file that provides the minimum set of features for Exwm:
(menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) (fringe-mode 1) (setq display-time-default-load-average nil) (display-time-mode t) (icomplete-vertical-mode 1) (exwm-systemtray-mode 1) (require 'exwm) (setq exwm-workspace-number 5) (setq exwm-input-global-keys `( ([?\s-r] . exwm-reset) ([?\s-w] . exwm-workspace-switch) ([?\s-&] . (lambda (command) (interactive (list (read-shell-command "$ "))) (start-process-shell-command command nil command))) ,@(mapcar (lambda (i) `(,(kbd (format "s-%d" i)) . (lambda () (interactive) (exwm-workspace-switch-create ,i)))) (number-sequence 0 9)))) (exwm-enable)
Note: you can also incorporate this code to an existing Emacs config. Just make sure to place (exwm-enable)
after your Exwm-related settings.
Press Ctrl + X, then Ctrl + S to save your new .emacs file.
Open your local user’s .xsession file, then paste the following block of code inside it:
xhost +SI:localuser:$USER gnome-settings-daemon & xsetroot -cursor_name left_ptr xset r rate 200 60 exec dbus-launch --exit-with-session emacs
Save your .xsessions file, then run the following command to create a new desktop entry for your system:
sudo nano /usr/share/xsessions/emacs.desktop
Paste the following inside your new .desktop file:
[Desktop Entry]<br>Name=Exwm<br>Exec=emacs<br>Type=Application
Save your new desktop file, then reboot your system to fully apply your new settings.
Good to know: Check out some of our picks for the best desktop environments for 2024.
Using Exwm for the First Time
At this point, you now have a basic installation of Emacs and Exwm running on your Ubuntu Linux desktop. To use it, click the Gear icon on your system’s login prompt, then select Exwm.
Login to your user account, then wait for a couple of seconds as Emacs and Exwm loads on your current session.
Once inside, the first thing that you can do is create a new window inside the current workspace. For that, press Ctrl + X, then 3. This will create a vertical window split, putting the window on the right side of the screen.
You can also press Ctrl + X, then 2 to create a horizontal split with the new window sitting at the bottom of your screen.
To move between different workspaces, press Win followed by the any number in your keyboard’s number row. For example, pressing Win + 3 will put focus on the third Exwm workspace.
Note: you can also press Alt + X, then type “exwm-workspace-switch” to access the switcher from the command buffer.
Running and Managing Programs in Exwm
Unlike a typical window manager, Exwm doesn’t come with a dedicated app launcher. Instead, Exwm uses a custom function that executes the input from the Emacs command buffer on an isolated Linux shell session.
To launch a program, press Shift + Win + 7, then provide the name of the app that you want to run. For instance, typing “firefox” will open the browser as a frame inside Exwm.
Note: Exwm will “take over” an existing Emacs frame instead of creating a new one.
To close a currently active window, press Ctrl + K. Doing this will completely kill the process but also leave a standard Emacs frame behind. You can press Ctrl + X, then 0 to remove the frame as well.
Configuring and Customizing Exwm
While the standard Exwm install is enough for most use cases, it’s possible to completely customize the desktop according to your needs. In this section, we’ll go through some of the tweaks that you can do to Exwm.
One of the easiest customizations that you can do is to change the desktop’s default screen resolution. To do that, open a terminal window by pressing Shift + Win + 7, then typing “gnome-terminal.”
Run xrandr on the terminal and take note of your monitor’s device name and the available resolutions for it. For instance, my monitor’s name is “Virtual-1” and I want to set my desktop’s resolution to 1360×768.
Paste the following command, then replace the “MONITOR” label with the name of your monitor and “RESOLUTION” with your target screen resolution.
xrandr --output MONITOR --mode RESOLUTION
Note: you can make make this change persistent across restarts by pasting the same command inside your .xsession file.
Reload your current Exwm session by pressing Alt + X, then typing “exwm-restart.”
FYI: Check out our handy guide on some of the best plugins for Hyprland today.
Creating New Keyboard Shortcuts in Exwm
Exwm doesn’t come with a lot of keybindings by default. This is because the window manager relies on both built-in Emacs keys as well as its users adding their custom shortcuts.
To add your own keybinds, open your .emacs file, then scroll to the section that contains “exwm-input-global-keys.”
Go inside the function and paste the following line of code:
([?\SHORTCUT] . FUNCTION)
Replace the “SHORTCUT” label with the key combo that you want. In my case, I want to use Win + Q as a shortcut so I will add “s-q.”
Note: Exwm uses c, s, and m to represent Ctrl, Win, and Alt keys respectively.
Change the “FUNCTION” label with the function that you want to associate with the shortcut.
Press Ctrl + X, then Ctrl + S to save your config, then restart your Exwm session.
Confirm that it’s working properly by pressing your custom keyboard shortcut.
Adding Passthrough Keys
On top of adding custom keybinds, it’s also possible to set passthrough keys in Exwm. These are shortcuts that doesn’t get interpreted on any X11 window, allowing you to access Emacs even while using a regular GUI program.
To add passthrough keys, open your .emacs file, then scroll down to the section on global Exwm keybinds.
Paste the following block of code just before the global Exwm shortcuts function. This will let you use the standard Ctrl + X, and Alt + X leader keys as well as access the help function:
(setq exwm-input-prefix-keys '(?\C-x ?\C-u ?\C-h ?\M-x ))
Save your Emacs config file, then restart the desktop to apply your new settings.
Converting your Emacs client into a bona fide window manager with Exwm is just a taste of what you can do with this highly flexible text editor. Keen on learning more? Find out why Emacs has become my favorite work and productivity app today.
Image credit: Mia Baker via Unsplash. All alterations and screenshots by Ramces Red.
Ramces Red –
Staff Writer
Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe