I use EXWM sometimes, but while i do appreciate it, i found myself using other WM and DE (either because i use my emacs config on another computer, since the config is in a usb stick, or other off-topic reasons) but because of the way i use it, which is the following:

 (use-package exwm
    :ensure t

      ;; necessary to configure exwm manually
      (require 'exwm-config)

      ;; fringe size, most people prefer 1 
      (fringe-mode 3)

      ;; emacs as a daemon, use "emacsclient <filename>" to seamlessly edit files from the terminal directly in the exwm instance

      ;; this fixes issues with ido mode, if you use helm, get rid of it

      ;; a number between 1 and 9, exwm creates workspaces dynamically so I like starting out with 1
      (setq exwm-workspace-number 1)

      ;; this is a way to declare truly global/always working keybindings
      ;; this is a nifty way to go back from char mode to line mode without using the mouse
      (exwm-input-set-key (kbd "s-r") #'exwm-reset)
      (exwm-input-set-key (kbd "s-k") #'exwm-workspace-delete)
      (exwm-input-set-key (kbd "s-w") #'exwm-workspace-swap)

      ;; the next loop will bind s-<number> to switch to the corresponding workspace
      (dotimes (i 10)
        (exwm-input-set-key (kbd (format "s-%d" i))
                            `(lambda ()
                               (exwm-workspace-switch-create ,i))))

      ;; the simplest launcher, I keep it in only if dmenu eventually stopped working or something
      (exwm-input-set-key (kbd "s-&")
                          (lambda (command)
                            (interactive (list (read-shell-command "$ ")))
                            (start-process-shell-command command nil command)))

      ;; an easy way to make keybindings work *only* in line mode
      (push ?\C-q exwm-input-prefix-keys)
      (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)

      ;; simulation keys are keys that exwm will send to the exwm buffer upon inputting a key combination
         ;; movement
         ([?\C-b] . left)
         ([?\M-b] . C-left)
         ([?\C-f] . right)
         ([?\M-f] . C-right)
         ([?\C-p] . up)
         ([?\C-n] . down)
         ([?\C-a] . home)
         ([?\C-e] . end)
         ([?\M-v] . prior)
         ([?\C-v] . next)
         ([?\C-d] . delete)
         ([?\C-k] . (S-end delete))
         ;; cut/paste
         ([?\C-w] . ?\C-x)
         ([?\M-w] . ?\C-c)
         ([?\C-y] . ?\C-v)
         ;; search
         ([?\C-s] . ?\C-f)))

      ;; this little bit will make sure that XF86 keys work in exwm buffers as well
      (dolist (k '(XF86AudioLowerVolume
      (cl-pushnew k exwm-input-prefix-keys))

      ;; this just enables exwm, it started automatically once everything is ready

I come to want to be able to start EXWM (as emacs start) only if no other DE or WM are in use. How could i make that work with my current config?


I look for the existence of a window manager using wmctrl -m. If that command outputs anything on stderr I assume there is no window manager and run the EXWM startup.

(when (get-buffer "*window-manager*")
  (kill-buffer "*window-manager*"))
(when (get-buffer "*window-manager-error*")
  (kill-buffer "*window-manager-error*"))
(when (executable-find "wmctrl")
  (shell-command "wmctrl -m ; echo $?" "*window-manager*" "*window-manager-error*"))

  ;; if there was an error detecting the window manager, initialize EXWM
  (when (and (get-buffer "*window-manager-error*")
             (eq window-system 'x))
    ;; exwm startup goes here
  • 1
    Nice, completely forgot about using wmctrl Sep 2 '20 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.