Switch to workspace where a link was opened in Firefox
When I open a link from workspace 1 (terminal, email, etc), it gets opened in the Firefox instance running on workspace 2.
I would like to automatically switch to / focus the Firefox window.
When I open a link from workspace 1 (terminal, email, etc), it gets opened in the Firefox instance running on workspace 2.
I would like to automatically switch to / focus the Firefox window.
This is not possible with i3 in the current version, but in the next version we can listen to title change events with the new i3ipc library to determine when the tab is opened and then focus the window. This script uses the JavaScript version of the library. You can find the latest version of this script here.
#!/usr/bin/env gjs
/*
This example shows how to make i3wm automatically switch to a browser that
has opened a new tab by using the new ipc "title change" event. This event
will be available in the next released version (after 4.7.2).
If you have a webpage open that changes the title without any user
interaction (rare, but possible), you may need to do some additional
filtering so it does not switch focus unexpectedly.
https://faq.i3wm.org/question/3434/switch-to-workspace-where-a-link-was-opened-in-firefox/
*/
const i3ipc = imports.gi.i3ipc;
let conn = new i3ipc.Connection;
let browser_re = /- Vimperator$|- Firefox$|- Chromium$/
conn.on('window::title', function(conn, e) {
if (browser_re.test(e.container.name)) {
e.container.command('focus');
}
});
conn.main();
Try create a script (e.g. ~/bin/mybrowser
) which changes the workspaces too. And set browser of your programs to ~/bin/mybrowser
:
#!/usr/bin/env bash
firefox $*
i3-msg workspace "web"
# blueyed's comment:
# i3-msg [class="Firefox"] focus
And how do you control which instance will open your URL? I think it's impossible: https://support.mozilla.org/hu/questions/975778
That's part of the problem.. :) Apart from that it affects other applications as well. When it is on the same workspace, the focus changes. It would be nice, if this would get done across workspaces, too - preferably with a setting ("focus stealing prevention").
Oh, understand. Do you know about wmctrl? Maybe you can use it. http://www.freedesktop.org/wiki/Software/wmctrl/
Asked: 2014-02-26 20:05:51 +0000
Seen: 582 times
Last updated: Mar 27 '14