Improved detection for resolution and refreshrates
Minor and Major bugs solved. - Disconnected interfaces now printed out for debug purpose - Preferred mode wont be skipped anymore if it equals to current mode. - Syntax error solved
This commit is contained in:
parent
afd583b77f
commit
c9fb732e2d
@ -20,30 +20,32 @@ for line in xrandr_data.splitlines():
|
|||||||
if line.startswith('Screen'):
|
if line.startswith('Screen'):
|
||||||
print_modelines(resolutions)
|
print_modelines(resolutions)
|
||||||
new_connection = False
|
new_connection = False
|
||||||
screen = line.split(':', maxsplit=1)[0].split()[-1]
|
screen = line.split(':', 1)[0].split()[-1]
|
||||||
new_screen = True
|
new_screen = True
|
||||||
print('Screen: {}'.format(screen))
|
print('Screen: {}'.format(screen))
|
||||||
|
elif ' connected ' in line:
|
||||||
elif new_screen and not new_connection and ' connected ' in line:
|
|
||||||
connection = line.split()[0]
|
connection = line.split()[0]
|
||||||
new_screen = False
|
new_screen = False
|
||||||
new_connection = True
|
new_connection = True
|
||||||
print('Connection: {}'.format(connection))
|
print('Display connected: {}'.format(connection))
|
||||||
resolutions = {}
|
resolutions = {}
|
||||||
|
elif ' disconnected ' in line:
|
||||||
elif new_connection and line.startswith(' '):
|
#Print debug information during detection
|
||||||
resolution, *refreshrates = line.split()
|
connection = line.split()[0]
|
||||||
|
print('Display disconnected: {}'.format(connection))
|
||||||
|
elif line.startswith(' '):
|
||||||
|
r = []
|
||||||
|
connectionDetails = list(filter(None,line.split(' ')))
|
||||||
|
#Get first entry with resolution. Rest can contain multiple refreshrates
|
||||||
|
resolution = connectionDetails.pop(0)
|
||||||
res_x, res_y = resolution.split('x')
|
res_x, res_y = resolution.split('x')
|
||||||
resolution = (int(res_x), int(res_y))
|
resolution = (int(res_x), int(res_y))
|
||||||
r = []
|
for refreshrate in connectionDetails:
|
||||||
for refreshrate in refreshrates:
|
|
||||||
if '+' in refreshrate:
|
if '+' in refreshrate:
|
||||||
current_mode = (resolution,
|
current_mode = (resolution, cleanup_refreshrate(refreshrate))
|
||||||
cleanup_refreshrate(refreshrate))
|
|
||||||
print('Current Mode: {}@{}'.format(*current_mode))
|
print('Current Mode: {}@{}'.format(*current_mode))
|
||||||
if '*' in refreshrate:
|
if '*' in refreshrate:
|
||||||
preferred_mode = (resolution,
|
preferred_mode = (resolution, cleanup_refreshrate(refreshrate))
|
||||||
cleanup_refreshrate(refreshrate))
|
|
||||||
print('Preferred Mode: {}@{}'.format(*preferred_mode))
|
print('Preferred Mode: {}@{}'.format(*preferred_mode))
|
||||||
r.append(cleanup_refreshrate(refreshrate))
|
r.append(cleanup_refreshrate(refreshrate))
|
||||||
resolutions[resolution] = r
|
resolutions[resolution] = r
|
||||||
|
Loading…
Reference in New Issue
Block a user