/usr/lib/plainbox-providers-1/checkbox/bin/fresh_rate_info is in plainbox-provider-checkbox 0.3-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# fresh_rate_info
#
# This file is part of Checkbox.
#
# Copyright 2012 Canonical Ltd.
#
# Authors: Shawn Wang <shawn.wang@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
"""
The fresh_rate_info got information from xrandr
"""
import re
import sys
import subprocess
def xrandr_paser(data=None):
'''return an array(xrandrs)'''
resolution = None
xrandrs = list()
for line in str(data).split('\n'):
for match in re.finditer('(.+) connected (\d+x\d+)\+', line):
connector = match.group(1)
resolution = match.group(2)
break
if resolution is None:
continue
for match in re.finditer('{0}\s+(.+)\*'.format(resolution),
line):
refresh_rate = match.group(1)
xrandr = {'connector': connector,
'resolution': resolution,
'refresh_rate': refresh_rate}
xrandrs.append(xrandr)
return xrandrs
def main():
'''main function'''
try:
data = subprocess.check_output(['xrandr', '--current'],
universal_newlines=True)
except subprocess.CalledProcessError as exc:
return exc.returncode
xrandrs = xrandr_paser(data)
for xrandr in xrandrs:
output_str = "Connector({0}):\t Resolution: {1} \t RefreshRate: {2}"
print(output_str.format(xrandr['connector'],
xrandr['resolution'],
xrandr['refresh_rate']))
if __name__ == '__main__':
sys.exit(main())
|