Find X resolution from a script when X isn't running.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Find X resolution from a script when X isn't running.
Does anyone know how to find the resolution that X runs at, when X may or may not be running and if it is, you don't have permission to access the display? (So xdpyinfo is no use.)
I want to resize a bunch of images for use as the background to a login screen. The script would be called either as a cronjob or as the post install script in an rpm. The images will be deployed to multiple machines with different resolution monitors attached. Resizing images from a script using imagemagick is trival, but my problem is how to know what dimensions to resize the image to. The only file I can find that contains the resolution is xorg.conf and I can't work out how to extract the default resolution from that with 100% reliability.
If you have permission, you could read the xorg.conf file and try to discern from that. Or you might read the log from the last start of X and that would tell you what resolution X used the last time it started.
Like I said, can't figure out a reliable way to get it from xorg.conf. Your log idea looks like it'll work though, cheers.
On SLED 10, which is what I'll be using, /var/log/Xorg.0.log can be grep-ed for 'Virtual size' to find a line which contains the relevant resolution. I've checked it on machines with three different resolution monitors so it seems to be reliable method of determining the resolution. Only minor niggle is that the resolution format is slightly different and the line contains different text depending on whether the video drivers is Intel or Nvidia. Should be easy enough to deal with though.
On my Kubuntu machine it seems the phrase to look for in Xorg.0.log is 'Virtual screen size'.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.