[wmii] Re: Raise a client

From: Jeremy Hankins <nowan_AT_nowan.org>
Date: Sun, 02 Jul 2006 19:02:14 -0400

Paul Malherbe <paul_AT_tartan.co.za> writes:

> Thanks for you input, it has really helped me!!

Glad I could help.

> What I was trying to do was write an event script which would raise the
> client which received focus.
>
> I have done it but the response is slow (acceptable), however I have had
> to write a bash script calling a python script as my bash is not very good.
> Could you maybe help me simplify it by using only one (python) script?

Take a look at http://www.nowan.org/wmii/, if you want. My (python)
wmiirc is there, as well as modwmii.py.

In modwmii.py I have this (Popen is from subprocess, in python 2.4):

class wmii_event(Popen):

    def read(self):
        return string.rstrip(self.stdout.readline())

    def close(self):
        # If wmii is exiting the wmiir process may already be dead.
        if not self.poll():
            os.kill(self.pid, signal.SIGTERM)

        return(self.wait())

So you could do (again, PIPE is from subprocess):

events = wmii_event(("wmiir", "read", "/event"), stdout = PIPE)

And loop with events.read().

-- 
Jeremy Hankins <nowan_AT_nowan.org>
PGP fingerprint: 748F 4D16 538E 75D6 8333  9E10 D212 B5ED 37D0 0A03
Received on Mon Jul 03 2006 - 01:02:26 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:10:27 UTC