summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-06-02 18:42:48 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-06-02 18:42:48 +0100
commit84c29c4f5bf596a34ac3f2d0844fdcdb894aed3a (patch)
treebfe8af22037a058d9056ce2bf21cc00399858611
parent3927b1347e66c721cbefbf559eeac7950dbda5fa (diff)
downloadkeyboard-python-84c29c4f5bf596a34ac3f2d0844fdcdb894aed3a.tar.bz2
Add get_repeat() to get repeat delay and rate
-rw-r--r--keyboardpython/__init__.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/keyboardpython/__init__.py b/keyboardpython/__init__.py
index 2996c7a..2638595 100644
--- a/keyboardpython/__init__.py
+++ b/keyboardpython/__init__.py
@@ -1,5 +1,18 @@
from key import *
+def get_repeat():
+ ''' try and get the repeat delay and rate from X '''
+ import subprocess
+ default_repeat_delay = 50
+ default_repeat_rate = 33
+ cmd = 'xset q | grep \"auto repeat delay\"'
+ proc = subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE)
+ output = proc.stdout.read()
+ if not output: return default_repeat_delay, default_repeat_rate
+ repeat_delay = output.split()[3]
+ repeat_rate = output.split()[-1]
+ return repeat_delay,repeat_rate
+
def echo(on=True):
import sys,termios
fd = sys.stdin.fileno()
@@ -51,7 +64,7 @@ def getkey(fd='default',timeout=32,buffersize=6):
- fd='default' will try and get this stdin.
- timeout in miliseconds
- - buffersize is passed to os.read, 6 is
+ - buffersize is passed to os.read, 6 is
enough for alt+F12 for example.
'''
import os,sys,time
@@ -70,7 +83,7 @@ def queue_keypresses(q,signal,fd='default',buffersize=6):
is True, deals with setup and teardown.
- fd='default' will try and get this stdin.
- - buffersize is passed to os.read, 6 is
+ - buffersize is passed to os.read, 6 is
enough for alt+F12 for example.
'''
import Queue