You are not logged in.

#26 2013-04-06 15:35:44

azb
Member
Registered: 2013-02-03
Posts: 15

Re: How do I get the active window title into a script?

Trilby wrote:

The C code definitely has absolutely nothing to do with the window manager.

I understand this makes no sense. But can't think of other variables.

EDIT: damn, the variable is the window type itself. Got successful fetches for Skype, Keepassx; segmentation fault for Chromium, Geany and Keepass2.

Last edited by azb (2013-04-06 15:39:53)

Offline

#27 2013-04-06 15:37:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: How do I get the active window title into a script?

You say it works on terminals, but not other windows, right?  What other windows have you tried.  I just tried it on mousepad, luakit, and firefox, and it worked fine.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#28 2013-04-06 15:45:27

azb
Member
Registered: 2013-02-03
Posts: 15

Re: How do I get the active window title into a script?

Indeed, most of the window types return 'Segmentation fault', only few other types succeed. Couldn't find other window types that work for me.

Got help from stackoverflow and solved it with python instead:

import Xlib.display

def get_active_window():
    display = Xlib.display.Display()
    window = display.get_input_focus().focus
    #wmname = window.get_wm_name()
    wmclass = window.get_wm_class()
    if wmclass is None: #or wmname is None:
        window = window.query_tree().parent
        wmclass = window.get_wm_class()
        #wmname = window.get_wm_name()
    winclass=wmclass[1]
    #print winclass
    return winclass

Last edited by azb (2013-04-06 19:49:47)

Offline

Board footer

Powered by FluxBB