Exwm, a minimalistic tiling window manager for Linux, effectively transforms Emacs into a fully functional graphical environment. This article will explore the advantages of utilizing Exwm, guide you through the installation process on Ubuntu 24.10, and demonstrate the capabilities of this innovative window manager.
Reasons to Choose Exwm as Your Window Manager
A major advantage of Exwm is its ability to seamlessly integrate various applications into your current Emacs workflow. This integration means you can leverage your familiarity with Emacs buffers in other applications, thereby enhancing your productivity over time.
Moreover, Exwm simplifies your desktop configuration by reducing the number of required config files. With Exwm, both your window manager and text editor can be configured using a single. emacs file, appealing to those who prefer a clean and organized system.
Lastly, Exwm is characterized by its speed and low resource usage. From my personal experience, starting the window manager from a powered-off state takes only a few seconds, and it consumes a mere 500 MB of RAM during a full day of use.
Installing Exwm in Your Emacs Setup
The initial step to install Exwm on Linux is ensuring you have Emacs and its related dependencies installed on your system. Execute the following command:
Launch your Emacs client, press Alt + X, and enter “package-install” to initiate the installation prompt.
In the prompt, type “exwm” and hit Enter to begin the installation of Exwm within Emacs.
To modify your configuration, press Ctrl + X, then Ctrl + F to open the file buffer, input “~/.emacs” in the prompt, and hit Enter.
Add the following code block to your. emacs file—this is a streamlined version of the default config that offers essential features for Exwm:
Press Ctrl + X, then Ctrl + S to save your edited. emacs file.
Next, open the local user’s. xsession file and insert the following code:
Save the. xsession file, and then run the following command to create a new desktop entry:
Insert the following content into your new. desktop file:
Save your desktop configuration file and reboot your system for the changes to take effect.
Getting Started with Exwm
You now have a functional installation of Emacs and Exwm running on your Ubuntu desktop. To utilize it, click on the Gear icon on your login screen and select Exwm as your environment.
Log into your account and observe as Emacs and Exwm initialize your session within a few moments.
Once you’re in, you can create a new window in your current workspace by pressing Ctrl + X and then 3. This will split the window vertically, placing it on the right side of your display.
To create a horizontal split with a new window at the screen’s bottom, press Ctrl + X, followed by 2.
Navigate between workspaces using Win and a number from your keyboard’s numeric row. For instance, pressing Win + 3 shifts your focus to the third Exwm workspace.
Launching and Managing Applications in Exwm
Exwm differs from conventional window managers as it lacks a specific app launcher. Instead, it employs a custom function that executes commands from the Emacs command buffer in a standalone Linux shell session.
To initiate an application, press Shift + Win + 7, and specify the desired application name. For example, entering “firefox” will open the browser as a frame within Exwm.
To terminate an active window, press Ctrl + K. This command will kill the ongoing process while leaving the corresponding Emacs frame open. You can eliminate this frame by pressing Ctrl + X and then 0.
Customizing Your Exwm Setup
The default Exwm installation is suitable for general usage, but you can personalize your desktop experience as needed. Here, we’ll review some handy customizations for Exwm.
One straightforward modification is adjusting your desktop’s screen resolution. To begin, open a terminal using Shift + Win + 7, and type “gnome-terminal.”
Run the command xrandr in the terminal to identify your monitor’s device name and available resolutions. For instance, if my monitor is named “Virtual-1” and I want a resolution of 1360×768, I’d take note of that.
Use the following command, replacing the “MONITOR” tag with your specific monitor name and “RESOLUTION” with your desired resolution:
Reload your Exwm session by pressing Alt + X and typing “exwm-restart.”
Establishing New Keyboard Shortcuts in Exwm
Exwm does not come pre-configured with many keybindings, as it relies on built-in Emacs shortcuts and the user’s ability to create custom keybindings.
To add your own key bindings, open the. emacs file and navigate to the section titled “exwm-input-global-keys.”
Insert the following line inside the function:
Substitute the “SHORTCUT” label with your preferred key combination. For instance, to use Win + Q, replace it with “s-q.”
Next, modify the “FUNCTION” label to match the function you want to connect with the shortcut.
Afterward, save your changes with Ctrl + X, then Ctrl + S, and restart your Exwm session.
Check that your newly created keyboard shortcut is functioning as intended.
Enabling Passthrough Keys
In addition to custom shortcuts, Exwm allows the setup of passthrough keys, which remain fully functional in any X11 window, enabling access to Emacs during the use of a standard GUI application.
To configure passthrough keys, access your. emacs file and navigate to the global keybinds section.
Insert the following code block right before the global keybindings function to enable the default Ctrl + X, and Alt + X keys alongside the help function:
Save your changes in the Emacs configuration, and restart the desktop to implement the new settings.
Transforming your Emacs client into a fully operational window manager with Exwm is just one aspect of the customized possibilities available to you with this adaptable text editor. Interested in discovering even more?
Image credits: Mia Baker via Unsplash. All modifications and images by Ramces Red.