Using 1autorandr for multimonitor detection, the script below is runned each time I dock my machine. In order to use spacemacs on the 4k monitor I curently must hit M-x zoom-frm-in.

What command could I add to have emacs's zoomed in on the fly as well?

$ cat /.config/autorandr/docked/postswitch

export GDK_SCALE=2
xrdb -merge ~/.XdefHiDPI


1 https://github.com/phillipberndt/autorandr

2 Answers 2


Your question title speaks about the command line. This answer instead talks about setting the font size in Emacs.

zoom-frm-in is a command in Emacs-Lisp library zoom-frm.el. It's purpose is to zoom inward interactively.

It sounds like you don't want to zoom in interactively but you instead want to start Emacs at the right zoom level - in other words, set a different zoom level.

Another way to put that is to say that you want to set the default font size to be bigger (since you are zooming in) than what it currently is.

You do that by setting the font you want by default, including its size. And you do that by customizing default-frame-alist.

Do this in the first frame you get after starting Emacs:

M-: (frame-parameter nil 'font)

That tells you what your default font is. Here's an example:

"-outline-Courier New-normal-normal-normal-mono-16-*-*-*-c-*-iso8859-1"

If you want a larger font that is similar to your current default font then customize option default-frame-alist, changing its font entry to be the same but with a larger size. For example, this font is larger than the one named above:

"-outline-Courier New-normal-normal-normal-mono-20-*-*-*-c-*-iso8859-1"

If, when you use M-x customize-option default-frame-alist, you do not see an entry for frame-parameter font then add one (click button INS to insert a new row, and enter the parameter name (font) and the parameter value (the new font name, with the larger size). Save your customization.

As an alternative to using Customize you can just put this in your init file, where <FONT> is the larger font you want:

(add-to-list 'default-frame-alist '(font . <FONT>))

When you restart Emacs it will use the larger font.

On the other hand, if you need a different default font size for different platforms that you use then you'll instead need to set frame parameter font differently for each platform/environment.

To do that, you'll need to put Emacs-Lisp code in your init file. The code will need to use function set-frame-font, passing it the appropriate font value for the current platform. This sets the font for all frames in the current Emacs session to <FONT> (which would be a string font name):

(set-frame-font <FONT> nil t)

I know nothing about autorandr and the code you show, which apparently determines the platform/environment. Perhaps someone else here can tell you how to test for that given platform/environment with Lisp. You would then do something like this, where <FONT1> and <FONT2> are the default fonts you want for the different environments:

  (if <some test for your platform/env> <FONT1> <FONT2>)

You might be able to use function window-system or getenv to check for the platform/environment. The former returns a name of your current platform. The latter returns the value of any environment variable.

See also the EmacsWiki page about setting fonts.

  • Thanks to your help I was able to get what I wanted, adding this line to the bash script that is triggered on the dock event: emacsclient -e '(set-frame-font "-ADBO-Source Code Pro-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1" nil t)'
    – jjk
    Jan 10, 2020 at 14:24

In file .XdefHiDPI, add the following line, adapting for your preferred font and size. I use the Hack TTF font at 14 point on a normal-resolution display.

emacs*font:                     Hack-14

See: (info "(emacs) X Resources") and https://sourcefoundry.org/hack/

Your Answer

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

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