You are not logged in.

#1 2009-02-20 10:42:41

skwo
Member
Registered: 2008-11-13
Posts: 133

Global key listener and getting information on windows in OpenBox

Hi all.
I never worked with this stuff so I have no idea what to search so I ask here.
How I can do a program that just sits on background and on specific key press prints some message or do something else (not important for now the action) in OpenBox (if it matters)?
Another program I would like to write is a program that can handle window actions, like getting window name (and probably ID if there is any), do X when new window created, do Y when window closed, Z when focused and etc, again in OpenBox.
Sorry for those lame question but I really never worked with specific DE/WM so I have no idea.
I don't need code just point me to the right direction
Thanks a lot!

Oh forgot, I'm going to write in C/C++ so if there is libraries preferably that they will exists for C/C++

Last edited by skwo (2009-02-20 10:52:40)


ArchLinux x86_64 on Dell Latitude E5410

Offline

#2 2009-02-20 17:28:24

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: Global key listener and getting information on windows in OpenBox

I know nothing about interfacing with openbox, but about sitting in the background and await key presses I use xbindkeys and it works very well. Seek in the wiki for more info.

Offline

#3 2009-02-20 17:35:18

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Global key listener and getting information on windows in OpenBox

/me is pointing in you in the right direction mainly because that's about as much as i know on the topics...

wmctrl, xdotools, xbindkeys (as mentioned), xmodmap, and ~/.config/openbox/rc.xml

Offline

#4 2009-02-20 17:59:38

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Global key listener and getting information on windows in OpenBox

Openbox already handles key mapping in rc.xml, as referenced above. And you could check out devilspie for the window action stuff.

Offline

#5 2009-02-20 19:56:55

skwo
Member
Registered: 2008-11-13
Posts: 133

Re: Global key listener and getting information on windows in OpenBox

Ok thanks but thats not what I'm looking for. Its all nice but I need to write my own software. Mainly what I want to do is to write keyboard layout switcher per window, since that was my problem with openbox. I want to write program that registers all open window into some linked list maybe + stores they layouts (at the beginning it will be the first layout), when window closed Ill remove it from list, when window opened Ill put into the list, and when window focused Ill find it in the list, get the layout currently written for that window and execute setxkbmap LAYOUT, and when some combination of keys pressed this program will switch the layout for current focused window.
So I would like to get, again, some direction where to look. Take for example devilspie: some how it can get info about opened windows, closed windows and do something with them.
Thanks again!


ArchLinux x86_64 on Dell Latitude E5410

Offline

#6 2009-02-21 04:00:55

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: Global key listener and getting information on windows in OpenBox

Wont this work?

Script to change the layout

setxkbmap *
get current window name(with wmctrl) and layout and write it to some temp file

Script to Alt-tab

#!/bin/pseudo
xdotools to send the alt-tab key to openbox
wmctrl to get the active window name
read the temp file and setxkbmap layout of the current window

Last edited by u_no_hu (2009-02-21 04:02:18)


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#7 2009-02-21 11:41:56

skwo
Member
Registered: 2008-11-13
Posts: 133

Re: Global key listener and getting information on windows in OpenBox

Its all nice, but now what I'm looking for. I rarely use Alt+Tab, imho panels are better.
Anyway I found that devilspie is using libwnck to watch for windows. Is there a better solution than libwnck?
And I still got problem with global key listener, so the program will react to some keys if it its not focused.
Thanks again smile

[edit]
Oh seems like libwnck will work only under gnome. Need a better solution.
[/edit]

Last edited by skwo (2009-02-21 11:44:22)


ArchLinux x86_64 on Dell Latitude E5410

Offline

#8 2009-02-22 19:20:02

skwo
Member
Registered: 2008-11-13
Posts: 133

Re: Global key listener and getting information on windows in OpenBox

Well at least someone? sad
I can't believe no one ever messed with this stuff.
I successfully got the name of root window via xlib, but it lists like 190  child windows, and some of them not even visible. And I still can't get how to react on specific actions like: Window Focused, Window Opened, Window Closed and etc.
There is not much documentation (or at least understandable) for XLib.
Thanks again!


ArchLinux x86_64 on Dell Latitude E5410

Offline

#9 2009-02-22 19:54:33

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Global key listener and getting information on windows in OpenBox

Why don't you try looking into some of panel's code out there ? You can look at the gnome code for this functionality, but beats me where you'd find it.

libwnck sounds about right, though...


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#10 2009-02-22 20:22:20

skwo
Member
Registered: 2008-11-13
Posts: 133

Re: Global key listener and getting information on windows in OpenBox

Well I don't know much about how each DE/WM manages their windows so I wasn't sure if the solution gnome uses will fit OpenBox, Ill check the source of the needed packages (gnome-settings-daemon I think).
Thanks!


ArchLinux x86_64 on Dell Latitude E5410

Offline

#11 2009-02-23 05:52:34

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: Global key listener and getting information on windows in OpenBox

Have a look at wmctrl source code... It works with all EWMH compliant WMs ...And its a single file so you can easily scrap what you need from it smile


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#12 2009-02-23 13:14:37

skwo
Member
Registered: 2008-11-13
Posts: 133

Re: Global key listener and getting information on windows in OpenBox

Wow thanks! It seems very useful!


ArchLinux x86_64 on Dell Latitude E5410

Offline

Board footer

Powered by FluxBB