From 9f9b3ff4e2077c37a53a24972d36bc3627798e22 Mon Sep 17 00:00:00 2001 From: khamidou Date: Wed, 30 Dec 2009 09:24:52 +0100 Subject: [PATCH] first commit --- README | 3 +++ grabber | 45 +++++++++++++++++++++++++++++++++++++++++++++ grabber-menu | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 README create mode 100755 grabber create mode 100755 grabber-menu diff --git a/README b/README new file mode 100644 index 0000000..6e0619a --- /dev/null +++ b/README @@ -0,0 +1,3 @@ +This is grabber, a small tool that supply word autocompletion in X11 environments. + +Grabber requires xte (xautomation), xbindkeys and dmenu. \ No newline at end of file diff --git a/grabber b/grabber new file mode 100755 index 0000000..e157bf5 --- /dev/null +++ b/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/grabber-menu b/grabber-menu new file mode 100755 index 0000000..cc6ded7 --- /dev/null +++ b/grabber-menu @@ -0,0 +1,3 @@ +#!/bin/sh + +dmenu < /usr/share/dict/words \ No newline at end of file -- 2.43.0