I use scratchpads in XMonad (my WM) extensively for quickly capturing (notes, TODOs etc) from anyhwere. I have an instance of Emacs running permanently in a workspace, and launch emacsclient as my scratchpad.

XMonad relies on WM_CLASS property of the frame(?) to identify if it should start new emacsclient instance, or if it should reuse it started previously. Before Emacs 27, this is how I used to start emacsclient from XMonad:

emacsclient -c --frame-parameters='(quote (name . "scratchmacs"))'

Before Emacs 27, doing a xprops | grep WM_CLASS would return "scrathmacs", but Emacs 27 keep giving "Emacs" instead. As a result, everytime I call my scratch-pad, a new window for emacsclient opens up :-(

I have done a bunch of googling and read through the documentation (albeit quite non-methodically), but got nowhere.

Evaluating (assoc 'name (frame-parameters)) in new emacsclient frame gives correct answer, i.e scratchmacs (but xprop for this frame still says emacs).

How can I set WM_CLASS of my choice for new emacsclient frames?

  • 3
    This bug report may be of interest: debbugs.gnu.org/41719
    – Basil
    Commented Aug 16, 2020 at 9:37
  • Yeah, this bug is pretty much it. Doesn't look like there is much I can do without headache. I am holding resorting to launch st -n scratchmacs and then launching emacsclient in it for now.
    – bitspook
    Commented Aug 16, 2020 at 11:14

1 Answer 1


I've pinged the bug report as it's still happening in Emacs 28, but in the meantime, I use the following:

# emacs.sh:
# call as ./emacs.sh [<file1>] [...]

flock "/run/lock/emacs-wmclassfix-$USER" bash -s "$@" <<'EOF' 
        emacsclient --no-wait --create-frame "$@" ||
        exec emacs --name emacs-title -f server-start "$@"
} &

If the server is started by calling emacs directly instead of letting emacsclient create one, then all goes to plan. This fully fixes the problem for me, without loss of functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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