Skip to content

Instantly share code, notes, and snippets.

@sahib
Created April 10, 2012 16:49
Show Gist options
  • Save sahib/2352808 to your computer and use it in GitHub Desktop.
Save sahib/2352808 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
def find_next_free_x_display():
for i in range(10):
try_path = "/tmp/.X" + str(i) + "-lock"
try:
with open(try_path,"r"):
print("-- " + str(i) + " is there")
except:
return i
else:
return -1
print(find_next_free_x_display())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment