]> khamidou — GitHub mirrors - config-files.git/commitdiff
first commit master
authorkhamidou <khamidou@gmail.com>
Wed, 30 Dec 2009 08:22:44 +0000 (09:22 +0100)
committerkhamidou <khamidou@gmail.com>
Wed, 30 Dec 2009 08:22:44 +0000 (09:22 +0100)
prog/grabber2/README [new file with mode: 0644]
prog/grabber2/grabber [new file with mode: 0755]
prog/grabber2/grabber-menu [new file with mode: 0755]

diff --git a/prog/grabber2/README b/prog/grabber2/README
new file mode 100644 (file)
index 0000000..305224b
--- /dev/null
@@ -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 (executable)
index 0000000..e157bf5
--- /dev/null
@@ -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 (executable)
index 0000000..cc6ded7
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+dmenu < /usr/share/dict/words
\ No newline at end of file