~ubuntu-branches/ubuntu/trusty/plainbox-provider-checkbox/trusty

« back to all changes in this revision

Viewing changes to bin/graphics_modes_info

  • Committer: Package Import Robot
  • Author(s): Zygmunt Krynicki
  • Date: 2014-04-07 19:00:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140407190031-rf836grml6oilfyt
Tags: 0.4-1
* New upstream release. List of bugfixes:
  https://launchpad.net/plainbox-provider-checkbox/14.04/0.4
* debian/watch: look for new releases on launchpad
* debian/rules: stop using pybuild and use manage.py
  {i18n,build,install,validate} instead. This also drops dependency on
  python3-distutils-extra and replaces that with intltool
* debian/control: drop X-Python3-Version
* debian/control: make plainbox-provider-checkbox depend on python and
  python2.7 (for some scripts) rather than suggesting them.
* debian/upstream/signing-key.asc: Use armoured gpg keys to avoid having to
  keep binary files in Debian packaging. Also, replace that with my key
  since I made the 0.3 release upstream.
* debian/source/lintian-overrides: add an override for warning about no
  source for flash movie with reference to a bug report that discusses that
  issue.
* debian/source/include-binaries: drop (no longer needed)
* debian/patches: drop (no longer needed)
* debian/plainbox-provider-checkbox.lintian-overrides: drop (no longer
  needed)
* Stop being a python3 module, move to from DPMT to PAPT

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# graphics_modes_info
 
5
#
 
6
# This file is part of Checkbox.
 
7
#
 
8
# Copyright 2012 Canonical Ltd.
 
9
#
 
10
# Authors: Alberto Milone <alberto.milone@canonical.com>
 
11
#
 
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.
 
15
 
 
16
#
 
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.
 
21
#
 
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/>.
 
24
 
 
25
from __future__ import print_function
 
26
from __future__ import unicode_literals
 
27
import sys
 
28
 
 
29
from checkbox_support.contrib import xrandr
 
30
 
 
31
 
 
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" %\
 
36
          (screen._screen,
 
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))
 
41
    print("Outputs:")
 
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()
 
49
            print("    Modes:")
 
50
            for m in range(len(modes)):
 
51
                mode = modes[m]
 
52
                refresh = mode.dotClock / (mode.hTotal * mode.vTotal)
 
53
                print("      [%s] %s x %s @ %s Hz" % (m,
 
54
                                                   mode.width,
 
55
                                                   mode.height,
 
56
                                                   refresh), end=' ')
 
57
                if mode.id == output._mode:
 
58
                    print("(current)", end=' ')
 
59
                if m == output.get_preferred_mode():
 
60
                    print("(preferred)", end=' ')
 
61
                print("")
 
62
        else:
 
63
            print("(not connected)")
 
64
 
 
65
 
 
66
def main():
 
67
    screen = xrandr.get_current_screen()
 
68
    try:
 
69
        print_modes_info(screen)
 
70
    except(xrandr.UnsupportedRRError):
 
71
        print('Error: RandR version lower than 1.0', file=sys.stderr)
 
72
 
 
73
if __name__ == '__main__':
 
74
    main()