]>
code.delx.au - bg-scripts/blob - lib/x11_helpers.py
2 # Copyright 2007 Greg Darke <starstuff@optusnet.com.au>
3 # Licensed for distribution under the GPL version 2, check COPYING for details
4 # Some little helper utils
6 import subprocess
, commands
, itertools
8 __all__
= ('getResolutions', )
10 def _seperateGroups(lines
):
14 if line
.strip() == '':
15 ret
.append(current_section
)
18 current_section
.append(line
)
20 ret
.append(current_section
)
24 xdpyinfo_status
, xdpyinfo_output
= commands
.getstatusoutput('xdpyinfo')
25 lines
= xdpyinfo_output
.splitlines()
26 groups
= _seperateGroups(xdpyinfo_output
.splitlines())
29 for screen_data
in itertools
.islice(groups
, 1, None, None):
30 _
, screen_number
= screen_data
[0].split()
31 # remove the leading and trailing characters
32 screen_number
= screen_number
[1:-1]
34 _
, screen_resolution_str
, _
, _
, _
= screen_data
[1].strip().split()
35 screen_resolution
= screen_resolution_str
.split('x')
37 screens
.append( (screen_number
, tuple(int(val
) for val
in screen_resolution
)))