Can I detect the display size/resolution in Emacs?
Asked Answered
D

2

20

I'd like to change the window/frame size of my XEmacs based on the current display resolution.

This is useful when I run my laptop either by itself or attached to a docking station with an external monitor. In either situation, I'd like Emacs to detect the primary screen resolution and adjust its main window frame size accordingly when I start it up.

Denverdeny answered 28/1, 2010 at 0:29 Comment(0)
S
18

The current display resolution is available using the following functions (both non-interactive).

(x-display-pixel-width)
(x-display-pixel-height)
Seger answered 28/1, 2010 at 3:48 Comment(1)
Exactly what I need. I intend to use the height to set the number of lines in my frame, and the width to position it within the display.Denverdeny
J
27

For a more cross-platform solution, look at

(display-pixel-width)
(display-pixel-height)

If what you actually want to do is set the Emacs window to full screen on start-up, check out maxframe.el.

Jessikajessup answered 28/1, 2010 at 20:31 Comment(2)
Unfortunately, these functions are not available in XEmacs.Denverdeny
Good to know, on both counts. I guess that with a couple of defalias, you could still use maxframe.el if you wanted.Jessikajessup
S
18

The current display resolution is available using the following functions (both non-interactive).

(x-display-pixel-width)
(x-display-pixel-height)
Seger answered 28/1, 2010 at 3:48 Comment(1)
Exactly what I need. I intend to use the height to set the number of lines in my frame, and the width to position it within the display.Denverdeny

© 2022 - 2024 — McMap. All rights reserved.