You are not logged in.

#1 2018-10-25 15:14:59

heyarne
Member
Registered: 2018-10-25
Posts: 10

[solved] Make openbox jump to "active" window

When I Firefox is visible on desktop 1 and I click a link on another desktop (say from Thunderbird or some messenger) I get no sort of feedback. The link opens silently in Firefox and I have to switch to it manually. Is it possible to automatically focus the desktop containing the Firefox window the link is opened in? I tried googling this but to no avail.

Edit: Just noted that this should probably be in GUI & Applications

Last edited by heyarne (2018-10-27 10:18:15)

Offline

#2 2018-10-25 19:30:08

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: [solved] Make openbox jump to "active" window

ok, all i know is that tint2 should be showing you a blinking icon (red frame) for the firefox window, wehn you open a link from another desktop.
why isn't even that happening?

i think it is possible to automatically switch to the window that is marked urgent.
for the moment, i have no idea if that is openbox', tint2's or firefox' task.
or maybe not: https://unix.stackexchange.com/question … ent-window

Offline

#3 2018-10-26 05:37:28

heyarne
Member
Registered: 2018-10-25
Posts: 10

Re: [solved] Make openbox jump to "active" window

I'm usig the repentance tint2 theme, so I don't know how the indication would look like from another desktop, but as far as I can tell there's nothing happening. But so not switching is default behavior?

Edit: OK I think I can see how this could work... so there's an "urgent" flag set on the window properties (WM_HINTS). This is on X' level, before Openbox comes into play. That flag is used for a couple of things: New mail in Thunderbird, Event coming up in some calendar app, whatever. So I guess it makes sense to not always switch to the window demanding attention, the flag isn't really fine-grained enough for this not to be confusing. Maybe I can set something up that polls this regularly.

Last edited by heyarne (2018-10-26 05:47:13)

Offline

#4 2018-10-26 07:47:45

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,668
Website

Re: [solved] Make openbox jump to "active" window

I think this is set in Firefox. Opening the link in a new tab with focus used to be Firefox's default behaviour, and may still be. I found this very annoying and went to huge lengths to keep in the current window so I could go down a list of links, say in an email, and open the interesting ones in new tabs in Firefox, checking them out later. This does seem to be easier now so maybe the default has changed.

@OP you want the opposite, I guess. You'll probably have to play with some settings in about:config to get things the way you want. For a start, have a look at
https://support.mozilla.org/en-US/questions/1199017
and
https://support.mozilla.org/en-US/questions/1177604
Especially, browser.link.open_newwindow.override.external is for links in other applications.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#5 2018-10-26 16:12:24

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: [solved] Make openbox jump to "active" window

To be able to switch desktop or window focus TO the browser, FROM a link in another application - I don't see a way to do that directly with OB settings.

@OP, if the tint2 theme you are using doesn't emphasize the urgent action state of the icon, then you could edit these lines:

urgent_nb_of_blink = <number>
task_urgent_background_id = <id number>

The default BL tint2 has

# ID 4 - task urgent
rounded = 1
border_width = 1
background_color = #888888 20
border_color = #ED2323 60

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#6 2018-10-26 20:49:11

heyarne
Member
Registered: 2018-10-25
Posts: 10

Re: [solved] Make openbox jump to "active" window

@damo The theme does highlight it, thanks. It just loses the highlight as soon as I switch to the desktop containing my Firefox window.

The problem is, I think, that Openbox doesn't switch desktops for it. If I have a messenger window active in front of Firefox and click a link, it opens a new tab in Firefox, switches to this tab and brings Firefox to the front. I can also see that this is happening on another desktop via the client-list-combined-menu. I guess @johnraff was right in way, it just doesn't switch to other desktops. Ideally I could additionally open tabs in the background from everywhere (by middle clicking for example), but I'm fine without that, too.

Anyway, it's just a minor nitpick. Thanks for your help so far!

Last edited by heyarne (2018-10-26 20:53:38)

Offline

#7 2018-10-27 05:58:49

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: [solved] Make openbox jump to "active" window

fwiw, i've seen this question popping up before.
unfortunately i don't remember if there's a definite, canonical way to change the behavior.
i think i linked you some stackexchange stuff with a (easily) compilable mini program, try that?
remember, this is gnu/linux, there's no such thing as impossible!

Offline

#8 2018-10-27 08:06:05

heyarne
Member
Registered: 2018-10-25
Posts: 10

Re: [solved] Make openbox jump to "active" window

OK, fine, haha. I spent the morning writing this script (disclaimer: I don't actually write bash). It's loosely based on an answer from the question you pointed to. The urgency was set correctly, so I just had to query some stuff and glue it together:

#!/usr/bin/env bash

####
# A small bash script to switch to urgent windows across desktops.
# The window title is optionally checked to see if it contains any of the
# given arguments.
#
# Usage:
#   switch-to-urgent-window.sh [filter...]
#
# Example:
#   switch-to-urgent-window.sh "Mozilla Firefox" "Mozilla Thunderbird"
####

for id in $(wmctrl -l | awk '{ print $1 }'); do
    # filter only windows demanding attention 
    xprop -id $id | grep -q "_NET_WM_STATE_DEMANDS_ATTENTION"
    if [ $? -eq 0 ]; then
	if [ $# -eq 0 ]; then
	    # no args given, switch to any needy window
            wmctrl -i -a $id
	    exit 0
	else
	    # match against our args and switch to first match
	    title="$(wmctrl -l | grep "^$id" | awk '{ $1=$2=$3=""; print $0 }')"
	    for filter in "$@"; do
		if [[ "$title" == *"$filter"* ]]; then
		    # bingo!
		    wmctrl -i -a $id
		    exit 0
		fi
	    done
        fi
    fi
done
exit 1

Where would I put this? Running it in a loop seems inefficient and error-prone. What if there's more then one urgent window matching the query for example?

Is there some kind of hook or event system that I could use? And if not, how do I initialize it? openbox/autostart seems wrong, considering it doesn't really have anything to do with openbox.

Last edited by heyarne (2018-10-27 08:07:49)

Offline

#9 2018-10-27 09:18:00

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,755

Re: [solved] Make openbox jump to "active" window

Tryin with this

<mousebind button="Up" action="Click">
  <action name="ForEach">
    <query>
      <urgent>yes</urgent>
    </query>
    <then>
      <action name="Raise"/>
    </then>
  </action>
</mousebind>

in rc.xml, but it's NOT doing anything, possibly worth pursuing for people smarter than me.

Last edited by brontosaurusrex (2018-10-27 09:21:14)

Offline

#10 2018-10-27 10:12:57

heyarne
Member
Registered: 2018-10-25
Posts: 10

Re: [solved] Make openbox jump to "active" window

Cool! While this seems very hacky, I added a sleep of 0.5s to my bash script above and added the following section to my ~/.config/openbox/rc.xml:

    <!-- vvv search for this vvv -->
    <context name="Client">
      <mousebind button="Left" action="Click">
        <!-- Focus Firefox from any Desktop -->
        <action name="Execute">
          <command>~/bin/switch-to-urgent-window.sh "Mozilla Firefox"</command>
        </action>
        <!-- / added action -->
      </mousebind>

This works! Seeing brontosaurusrex' snippet makes me think it might be possible using only the rc.xml, but I'm fine with my solution for now. Thanks for all the help!

Last edited by heyarne (2018-10-27 10:20:01)

Offline

#11 2018-10-27 14:23:54

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: [solved] Make openbox jump to "active" window

brontosaurusrex wrote:

Tryin with this

...

in rc.xml, but it's NOT doing anything, possibly worth pursuing for people smarter than me.

hallelujah!

dear op, this works without any scripting at all, provided you are willing to perform a simple mouse action to get to the urgent window:

<context name="Titlebar">
(...)
<mousebind button="Up" action="Press">
  <action name="ForEach">
    <query target="default">
      <urgent>yes</urgent>
    </query>
    <then>
      <action name="Raise"/>
      <action name="Focus"/>
    </then>
  </action>
</mousebind>
(...)
</context>

this will bring you to an urgent window by scrolling Up on any window titlebar (make sure you first comment out the default action for "Up", which is to roll up/ shade the window).
of course you can change the context and the action, or bind it to a key instead.

Offline

Board footer

Powered by FluxBB