2
# -*- coding: utf-8 -*-
6
# This file is part of Checkbox.
8
# Copyright 2012 Canonical Ltd.
10
# Authors: Alberto Milone <alberto.milone@canonical.com>
12
# Checkbox is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU General Public License version 3,
14
# as published by the Free Software Foundation.
17
# Checkbox is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
22
# You should have received a copy of the GNU General Public License
23
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
25
from __future__ import print_function
26
from __future__ import unicode_literals
29
from checkbox_support.contrib import xrandr
32
def print_modes_info(screen):
33
"""Print some information about the detected screen and its outputs"""
34
xrandr._check_required_version((1, 0))
35
print("Screen %s: minimum %s x %s, current %s x %s, maximum %s x %s" %\
37
screen._width_min, screen._height_min,
38
screen._width, screen._height,
39
screen._width_max, screen._height_max))
40
print(" %smm x %smm" % (screen._width_mm, screen._height_mm))
42
for o in list(screen.outputs.keys()):
43
output = screen.outputs[o]
44
print(" %s" % o, end=' ')
45
if output.is_connected():
46
print("(%smm x %smm)" % (output.get_physical_width(),
47
output.get_physical_height()))
48
modes = output.get_available_modes()
50
for m in range(len(modes)):
52
refresh = mode.dotClock / (mode.hTotal * mode.vTotal)
53
print(" [%s] %s x %s @ %s Hz" % (m,
57
if mode.id == output._mode:
58
print("(current)", end=' ')
59
if m == output.get_preferred_mode():
60
print("(preferred)", end=' ')
63
print("(not connected)")
67
screen = xrandr.get_current_screen()
69
print_modes_info(screen)
70
except(xrandr.UnsupportedRRError):
71
print('Error: RandR version lower than 1.0', file=sys.stderr)
73
if __name__ == '__main__':