Skip to content

Instantly share code, notes, and snippets.

@SergKolo
Created August 25, 2016 07:18
Show Gist options
  • Save SergKolo/fda81cd7c04606d82d9c1de92209d441 to your computer and use it in GitHub Desktop.
Save SergKolo/fda81cd7c04606d82d9c1de92209d441 to your computer and use it in GitHub Desktop.
import subprocess
output = subprocess.check_output(['xrandr']).decode().split('\n')
found = None
for item in output:
if ' connected' in item:
found = True
print(item.split()[0])
if found and item.startswith(' '):
print(item.split()[0])
if ' disconnected ' in item:
found = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment