From: khamidou Date: Wed, 30 Dec 2009 08:22:44 +0000 (+0100) Subject: first commit X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=HEAD;p=config-files.git first commit --- diff --git a/prog/grabber2/README b/prog/grabber2/README new file mode 100644 index 0000000..305224b --- /dev/null +++ b/prog/grabber2/README @@ -0,0 +1,3 @@ +This is grabber, a small tool that supply word autocompletion in X11 environments. + +Grabber requires xte (xautomation) and xbindkeys. \ No newline at end of file diff --git a/prog/grabber2/grabber b/prog/grabber2/grabber new file mode 100755 index 0000000..e157bf5 --- /dev/null +++ b/prog/grabber2/grabber @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import sys +import fcntl +import signal +from os import popen + +# Try to acquire the file lock : + +def bail_out(msg): + print msg + sys.exit(-1) + +lockfile = "/tmp/grabber" + os.getpid() + +try: + fd = open(lockfile, "wt") +except IOError: + bail_out("Unable to open /tmp/grabber - exiting") + +try: + fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) +except IOError: + # Grabber is already running - it is has been invoked a second time it's because + # the user want to leave automated grab mode. + +try: + xte_pipe = popen("xte", "w") +except IOError: + bail_out("Unable to open xte pipe") + +while True: + menu_pipe = popen("./grabber-menu", "r") + + for c in menu_pipe.read(): + xte_pipe.write("key " + c + "\n") + +# +# Unlock the file at the end +try: + fcntl.lockf(fd, fcntl.LOCK_UN) +except IOError: + bail_out("Unable to release lock on file") + + diff --git a/prog/grabber2/grabber-menu b/prog/grabber2/grabber-menu new file mode 100755 index 0000000..cc6ded7 --- /dev/null +++ b/prog/grabber2/grabber-menu @@ -0,0 +1,3 @@ +#!/bin/sh + +dmenu < /usr/share/dict/words \ No newline at end of file