For example, no matter in which workspace I start Firefox, I want it to launch in workspace 2. In i3wm
I can do this with assign [class="(?i)firefox"] $workspace2
.
2 Answers
You can use exwm-manage-finish-hook
to perform functions when a window has loaded. Combine that with exwm-class-name
and exwm-workspace-move-window
and you could do something like this:
(require 'subr-x) ;; Because of when-let
(defvar exwm-workspace-window-assignments
'(("Firefox" . 2)
("Thunderbird" . 3))
"An alist of window classes and which workspace to put them on.")
(add-hook 'exwm-manage-finish-hook
(lambda ()
(when-let ((target (cdr (assoc exwm-class-name exwm-workspace-window-assignments))))
(exwm-workspace-move-window target))))
So now a window named Firefox would end up on workspace 2, while Thunderbird would end up on workspace 3. You could add more entries to exwm-workspace-window-assignments
if you want. Keep in mind that the workspace need to exist before trying to move a window to it.
The code snippet above needs Emacs 25, because of when-let
.
There is a way to set this using EXWM
settings (it is possible that this option did not exist at the time the question was first answered):
(setq exwm-manage-configurations
'((string= exwm-instance-name "firefox")
workspace 2))
You can also set this variable with M-x customize-variable
Ret exwm-manage-configurations
.