Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am developing a personal project/idea for a headless Raspberry Pi that works without a GUI display. I am working on a text graphicsesque design.

As the Raspberry Pi allows one to plug into most any screen, I want to be able to determine the screens resolution so I can create an optimal display.

My problem lies in actually getting the screens resolution. I have tried a few methods in python, such as messing with xrandr and the the Tkinter module, but both have the same problem. There technically isn't a screen, just a console. Text editors like vim seem to be able to fit themselves without any problem.

Can I get a screens resolution, without having to load up a display? All suggestions welcome, but my proficiencies are in the Python, C++, Java and Bash range.

share|improve this question
add comment

migrated from stackoverflow.com Jul 7 '13 at 21:23

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

You can look in /sys/class/drm/card*/*/modes:

for card in /sys/class/drm/card*/* ; do
    echo "$card: $(head -n 1 $card/modes)"
done

should output something like

/sys/class/drm/card0/card0-LVDS-1: 1024x768
/sys/class/drm/card0/card0-VGA-1: 1280x1024
share|improve this answer
    
Ive also found stty useful "os.popen('stty size', 'r').read().split" . It gives you the consoles row, column value without having to rely on /drm/card, as I've noticed this is missing in my vm version of crunchbang for some reason –  PiMan Aug 19 '13 at 12:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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