#!/usr/bin/env python
section = file('.xconfigure/modules/keyboardrepeatrate/section.txt')
#open the file containing the correct section of xorg.conf
loopy = True
#set up a loop
linecombine = ''
#define linecombine as a String
count = 0
while loopy:
#start the loop
line = section.readline()
#read each line of xorg.conf
linefind = line.count('AutoRepeat')
#find AutoRepeat in xorg.conf
lenline = len(line)
#find the length of line
if lenline == 0:
count = count + 1
#if the line is empty
if count == 2:
loopy = False
#stop the loop
linex = line
#set the linex variable to be the same as line
else:
count = 0
if linefind == 0:
#if the line doesn't contain AutoRepeat
linex = line
#set the linex variable
else:
if line.count('#') == 0:
#if it isn't a comment
change2 = int(raw_input('Enter your desired keyboard auto repeat delay rate (ms): '))
#asks for the rate they want the auto repeat delay to be
change3 = int(raw_input('Enter your desired keyboard refresh rate (ms): '))
#asks for the refresh rate
linex = ' Option "AutoRepeat" ' + '"'+ str(change2) + ' ' + str(change3) + '"' +'\n'
#put the line together into linex
else:
linex = line
linecombine = linecombine + linex
#adds the linex to the end of previous line
section.close()
#close file in read mode
section = file('.xconfigure/modules/keyboardrepeatrate/section.txt', 'w')
#open the file in write mode
section.write(linecombine)
#write your finished line into the file