/usr/bin/xrandr-tool is in xdiagnose 2.5.2ubuntu0.1.
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 | #!/usr/bin/python
import sys
import re
import subprocess
if __name__ == "__main__":
# TODO: optparse
if len(sys.argv) < 2:
print "Usage: xrandr-tool <command>"
print
print "Commands:"
print " outputs"
print " current-resolution [output-name]"
print " resolutions [output-name]"
sys.exit(1)
command = sys.argv[1]
output_name = None
if len(sys.argv) > 2:
output_name = sys.argv[2]
re_output = re.compile("^(.*) (?:disconnected|connected) (.*)")
re_res = re.compile("^ (\d+x\d+) *(.*)")
# The results from xrandr are given in terms of the available display devices.
# One device can have zero or more associated modes. Unfortunately xrandr
# indicates this through indentation and is kinda wordy, so we have to keep
# track of the context we see mode names in as we parse the results.
process = subprocess.Popen(['xrandr'], stdout=subprocess.PIPE)
xrandr_stdout, xrandr_stderr = process.communicate()
current_output_name = None
for line in xrandr_stdout.split("\n"):
m = re_output.match(line)
if m:
current_output_name = m.group(1)
if command == "outputs":
print current_output_name
if "resolution" in command:
m = re_res.match(line)
if m and current_output_name == output_name:
res = m.group(1)
if command == "current-resolution":
if line.find('*') != -1:
print res
else:
print res
|