#!/usr/bin/python
import os
def is_in_dic(char, dic):
i = 0
while i < len(dic):
if dic[i] == char:
return True
i = i + 1
return False
def get_part_after_text(source, string):
i = 0
found_i = 0
found = ""
number = ""
while i < len(source):
if source[i] == string[found_i]:
found = found + source[i]
found_i = found_i + 1
else:
found = ""
found_i = 0
if found == string:
i = i + 1
# if string was found, get the number behind it
numbers = {0 : "0", 1 : "1", 2 : "2", 3 : "3", 4 : "4", 5 : "5", 6 : "6", 7 : "7", 8 : "8", 9 : "9", 10 : "a", 11 : "b", 12 : "c", 13 : "d", 14 : "e", 15 : "f"}
while i < len(source) and is_in_dic(source[i], numbers):
number = number + source[i]
i = i + 1
return number
break
i = i + 1
return False
output = os.popen("xauth -vqibn list").read()
hexid = get_part_after_text(output, "MIT-MAGIC-COOKIE-1 ")
os.popen("xauth -vqibn add :1.0 MIT-MAGIC-COOKIE-1 " + hexid)