You are not logged in.

#1 2016-12-14 21:20:01

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Openbox -- Detect Application Desiring Attention

I have been in an Openbox mood of late, but I miss the bar in i3.  I have been using lemonbar with a script I wrote in Python that allows me to replicate the workspaces functionality of the i3 bar; that, combined with some keybindings in rx.xml let me switch workspaces with keybindings, highlight the active workspace, and "go back" to the previous workspace if you keyboard select the presently active workspace -- all very much like the i3 bar.

What I cannot figure out is how to detect when an application running on any workspace wants focus.  In i3wm, the workspace indicator will (in my system's case) highlight with a red background when something wants focus on that workspace.  For example, following a hyperlink in Thunderbird on workspace 6 might cause a browser on workspace 2 to open a tab.  I would like for my indicator for workspace two to indicate this.

My Google foo has failed me -- I've tried search terms such as "openbox application need focus detect" and have found squat. I've also spent a fair amount of quality time in http://openbox.org/wiki/Help:Contents and man wmctl
Can anyone point me in the right direction?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#2 2016-12-14 21:59:01

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: Openbox -- Detect Application Desiring Attention

ewaller wrote:

In i3wm, the workspace indicator will (in my system's case) highlight with a red background when something wants focus on that workspace.  For example, following a hyperlink in Thunderbird on workspace 6 might cause a browser on workspace 2 to open a tab.  I would like for my indicator for workspace two to indicate this.

Do you mean the urgency hint? It is one of the bits set on the WM_HINTS property (defined in the EWMH standard) and is intended for marking X11 windows as "urgent". Typical usage of that would be status bars highlighting the window name, or the window manager setting a special border colour (if the application/WM properly supports that property).

You can test this easily with `xprop` and some terminal that sets the urgency hint whenever a bell character is echoed (e.g. urxvt with `URxvt.urgentOnBell: true`):

  1. In one terminal, run

    $ xprop -spy WM_HINTS

    then click on the second terminal window to have xprop listen to changes on that terminal window's `WM_HINTS` property.

  2. In the selected terminal, echo a bell character:

    $ printf "\a"

    You should now see xprop output a property change:

    WM_HINTS(WM_HINTS):
    		Client accepts input or input focus: True
    		Initial state is Normal State.
    		window id # of group leader: 0x2a0000a
    		The urgency hint bit is set

    More importantly, your i3 bar should somehow give a visual clue (although I'm not sure whether it only does that for windows on unfocused workspaces - perhaps you'd need to add a `sleep` somewhere and change to another workspace to see the effect).

I don't know how to interact with X11 windows from python, though. But if you manage to query (or listen to) window property changes, you should be able to react accordingly.

Last edited by ayekat (2016-12-14 22:01:56)


pkgshackscfgblag

Offline

#3 2016-12-14 22:06:56

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: Openbox -- Detect Application Desiring Attention

Okay, that is great information of which I was unaware.  Let me do my due diligence and I'll get back.

Thanks.

Edit:  Okay, I now see how to do it with polling, wmctrl and xprop.  Now I need to see if I can find a hook or callback when one gets set.

Last edited by ewaller (2016-12-14 22:26:57)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2016-12-14 23:06:56

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

Re: Openbox -- Detect Application Desiring Attention

FWIW, this is a lemonbar question, not an openbox question.  Openbox sets the proper hint, it's up to the panel/bar to display it in some way.  I'm not familiar with lemonbar, so I don't know if it's a configuration issue, or if lemonbar just doesn't have this feature.  Tint2 will highlight urgent windows/desktops.

EDIT: It seems from the above that my points may be moot, but still worth having for future reference.  I see lemonbar may not really do anything on it's own except display the input it is given.  So using something like xprop or wmctrl to read urgent hints would be the only way to go.  If your input into lemonbar is just a shell script, this will require polling leading to the trade off of responsiveness of the hint showing up and wasted processing.  Writing your lemonbar input in a language with Xlib bindings would allow you to respond directly to the X11 event of the hint changing.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-12-14 23:42:47

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: Openbox -- Detect Application Desiring Attention

Yeah.  I have it set up so that it is a python script that opens lemonbar as a subprocess and communicates with it through pipes.  So, I could try using one of the Xlib libraries for Python, but they seem experimental at best.

It is supposed to rain here this weekend.  Maybe this is a good time to sit down for a couple days and figure out how to do the whole task myself - bar and all.  In C.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB