box.matto.nl
Enjoying Open Source Software

Switched to the EXWM window manager

After about two decades using the ratpoison window manager, the original tiling window manager, I switched to the EXWM window manager on my laptops, running FreeBSD.

EXWM

EXWM (Emacs X Window Manager) is a full-featured tiling X window manager for Emacs.

It is a tiling window manager that also supports floating windows, but I haven't used that.

EXWM, like ratpoison, is controlled with the keyboard, no mouse interaction is necessary.

Basic configuration

With little EXWM experience I only use a basic configuration, copied from the EXWM Wiki, with some extra key chords to quickly start often used applications.

This configuration uses the super-key (the key with the ugly Windows symbol) as prefix.

(use-package exwm)
(setq exwm-workspace-number 5)

(add-hook 'exwm-update-class-hook
          (lambda () (exwm-workspace-rename-buffer exwm-class-name)))
;; Global keybindings.
(setq exwm-input-global-keys
      `(([?\s-r] . exwm-reset) ;; s-r: Reset (to line-mode).
        ([?\s-g] . (lambda () (interactive) (start-process "links" nil "links" "-g")))
        ([?\s-m] . (lambda () (interactive) (start-process "librewolf" nil "librewolf")))
        ([?\s-p] . (lambda () (interactive) (start-process "~/bin/windowshot.sh")))
        ([?\s-t] . (lambda () (interactive) (start-process "terminal" nil "urxvt")))
        ([?\s-v] . (lambda () (interactive) (start-process "vncviewer" nil "vncviewer" ":5900")))
        ([?\s-w] . exwm-workspace-switch) ;; s-w: Switch workspace.
        ([?\s-&] . (lambda (cmd) ;; s-&: Launch application.
                     (interactive (list (read-shell-command "$ ")))
                     (start-process-shell-command cmd nil cmd)))
        ;; s-N: Switch to certain workspace.
        ,@(mapcar (lambda (i)
                    `(,(kbd (format "s-%d" i)) .
                      (lambda ()
                        (interactive)
                        (exwm-workspace-switch-create ,i))))
                  (number-sequence 0 9))))
(exwm-enable)

EXWM supports the use of so-called workspaces. A workspace holds one or more windows.

Select and switch to a workspace by holding the super-key and pressing a number key. The numbering of the workspaces start at zero.

The X-windows are managed by EXWM, each window is shown in an Emacs buffer. Switching to a buffer is done in the normal way, e.g, with C-x b.

Input simulation.keys.

These are key chords that send simulated keyboard actions to the application. I opted for only a minimal number of simulation.keys.

(setq exwm-input-simulation-keys
      '(([?\M-w] . [?\C-c])
        ([?\C-y] . [?\C-v])
        ([?\C-s] . [?\C-f])))

With this, the standard Emacs key chords for copy, paste and search can be used in the application.

Preferred workspaces

For the most important external applications configure the preferred workspace.

(setq exwm-manage-configurations
      '(((string= exwm-instance-name "librewolf")
         workspace 1)
        ((string= exwm-instance-name "Navigator")
         workspace 1)
        ((string= exwm-instance-name "urxvt")
         workspace 2)
        ((string= exwm-instance-name "libreoffice")
         workspace 3)
        ((string= exwm-instance-name "vncviewer")
         workspace 4)))

Char-mode versus line-mode

EXWM uses two different input methods.

  • In line-mode EXWM intercepts all key events and sends applications only keys not explicitly assigned.
  • In char-mode only responds to globally grabbed key sequence, other key evens are send to the application.

Switch to char-mode with C-c C-k, and switch back to line-mode with s-r (EXWM reset).

In line-mode use C-c C-q to send specific keys to the application, e.g. to send Ctrl-C to an application, use C-c C-q C-c.

Open a file with a specific application

I am adopting more and more of the "Emacs way". The switch to EXWM is part of this.

Adopting the use of Dired is another part of this. This also affects the way I open a file with a specific application. I was used to do this on the command line, e.g. mupdf ~/Downloads/some-ebook.epub. Now I jump to Dired, and open a file from there. To use a specific application, just press & and Emacs will ask which application to use.

Tags:

⇽ Set up an alternative Emacs configuration


Made with ♥ by a human — no cookies, no trackers.
Proud member of the 250kb.club, the no-JS.club, the Blogroll.Club, and the Bukmark.Club.
Don’t let a billionaire’s algorithm control what you read — use an RSS feed reader.