mirror of
https://codeberg.org/privacy1st/rotate-screen
synced 2024-11-22 21:39:33 +01:00
fix get_current_orientation
This commit is contained in:
parent
bdefcf18d8
commit
d51d598ac1
@ -69,13 +69,18 @@ def get_current_orientation(screen: str):
|
|||||||
- stdout includes line: eDP connected primary 2880x1620+0+0 (0x55) normal (normal left inverted right x axis y axis) 344mm x 194mm
|
- stdout includes line: eDP connected primary 2880x1620+0+0 (0x55) normal (normal left inverted right x axis y axis) 344mm x 194mm
|
||||||
- screen: eDP
|
- screen: eDP
|
||||||
- returns: normal
|
- returns: normal
|
||||||
|
|
||||||
|
Example:
|
||||||
|
- stdout includes line: eDP-1 connected 1920x1280+0+0 (0x46) normal (normal left inverted right x axis y axis) 222mm x 148mm
|
||||||
|
- screen: eDP-1
|
||||||
|
- returns: normal
|
||||||
"""
|
"""
|
||||||
stdout = execute(['xrandr', '--query', '--verbose'])
|
stdout = execute(['xrandr', '--query', '--verbose'])
|
||||||
pattern = re.compile(rf'^({re.escape(screen)}\s.*)$', flags=re.MULTILINE)
|
# pattern = re.compile(rf'^{re.escape(screen)} .* \([^\)]+\) (\S+) \([^\)]+\) .*$', flags=re.MULTILINE)
|
||||||
|
pattern = re.compile(rf'^{re.escape(screen)} connected [^\(]+ \([^\)]+\) (\S+) \([^\)]+\) [^\(]+$', flags=re.MULTILINE)
|
||||||
match = pattern.search(stdout)
|
match = pattern.search(stdout)
|
||||||
if match is None: raise Exception(f'Did not find screen {screen} in stdout:\n{stdout}')
|
if match is None: raise Exception(f'Did not find screen {screen} in stdout:\n{stdout}')
|
||||||
line = match.group(1)
|
return match.group(1)
|
||||||
return line.rsplit()[5]
|
|
||||||
|
|
||||||
|
|
||||||
def is_connected(screen: str):
|
def is_connected(screen: str):
|
||||||
|
Loading…
Reference in New Issue
Block a user