You are not logged in.

#1 2014-07-28 15:11:28

nexutix
Member
Registered: 2014-07-28
Posts: 8

[Solved] How to open n different URLs in n different browser windows

Suppose there are 5 windows of dwb browser open. Using a script I want to open URL1 in first window, then URL2 in second and so on...

Any other browser would do too.

Last edited by nexutix (2014-07-28 22:04:34)

Offline

#2 2014-07-28 17:28:53

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [Solved] How to open n different URLs in n different browser windows

I am not sure about dwb, but with firefox, you can do something like the following:

for urls in url1 url2 url3 url4 url5; do
    firefox -new-window "$url"
done

Alternatively,

put the urls in an array:

urls=(url1 url2 url3)

for url in "${urls[@]}"; do 
    firefox -new-window "$url"
done

Last edited by x33a (2014-07-28 17:31:46)

Offline

#3 2014-07-28 17:45:01

nexutix
Member
Registered: 2014-07-28
Posts: 8

Re: [Solved] How to open n different URLs in n different browser windows

x33a wrote:

I am not sure about dwb, but with firefox, you can do something like the following:

Sorry I wasn't clear enough. I need the windows to be specific.

Say, I have window 1 on workspace 1, window 2 on workspace 2 and so on... Now I have URL1, URL2 and so on. I only want to open URL1 on workspace 1, URL2 on workspace 2 and so on. Then I will repeat that with new set of urls via a script.

I have a just satisfactory solution with conkeror: (but it would be great to have a setup with a standard browser like firefox or chromium):

Copy pasting from somewhere else:

So after a little tinkering around, I found this solution:

First I installend `xulrunner`. Then got conkeror .tar.gz from its git, extracted it and copied the folder twice; effectively creating 3 folders. Now in each folder, I edited each one's application.ini with

    Name=conkeror1
    Name=conkeror2
    Name=conkeror3

Then I created .conkerorrc in home folder and added one single line:

    url_remoting_fn = load_url_in_current_buffer;

You can also set it to `url_remoting_fn = load_url_in_new_buffer;` if you want newly issued urls to open in new buffers (tabs).

Then simply issued commands like this:

    xulrunner conkeror1/application.ini "URL1"
    xulrunner conkeror2/application.ini "URL2"
    xulrunner conkeror3/application.ini "URL2"

Voila! Each window is targeted separately!

Offline

#4 2014-07-28 17:46:54

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

Re: [Solved] How to open n different URLs in n different browser windows

Do you need to have the windows open first, or would a solution to open 5 urls in 5 windows on 5 different workspaces work?


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

Offline

#5 2014-07-28 17:48:20

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [Solved] How to open n different URLs in n different browser windows

Which DE/WM are you using? And how many workspaces have you got?

Offline

#6 2014-07-28 18:44:18

nexutix
Member
Registered: 2014-07-28
Posts: 8

Re: [Solved] How to open n different URLs in n different browser windows

x33a wrote:

Which DE/WM are you using? And how many workspaces have you got?


I am using an i3 session for my studies. Config starts 10 conkeror windows on login on 10 different workspaces and a python script with Tkinter GUI which issues URLs via command line to open these 10 URLs in those 10 windows on respective workspaces. As .conkerorrc has a directive to replace new URLs in current buffer (tab) it neither opens new windows nor does it eat up RAM by creating new buffers in every window.

Conkeror is little buggy; so a search for standard browser. Wish there's a way to embed chromium's engine like Xulrunner.


Trilby wrote:

Do you need to have the windows open first, or would a solution to open 5 urls in 5 windows on 5 different workspaces work?

I could assign different window class to firefox windows to handle i3's config (using -app option and changing vale of "Name" directive in application.ini), but cannot target specific window for specific URL. That's the obstacle.

Last edited by nexutix (2014-07-28 18:50:33)

Offline

#7 2014-07-28 19:34:53

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [Solved] How to open n different URLs in n different browser windows

Independent of WM/DE, wmctrl and xdotool might help you.

Offline

#8 2014-07-28 19:59:04

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

Re: [Solved] How to open n different URLs in n different browser windows

nexutix wrote:
Trilby wrote:

Do you need to have the windows open first, or would a solution to open 5 urls in 5 windows on 5 different workspaces work?

I could assign different window class to firefox windows to handle i3's config (using -app option and changing vale of "Name" directive in application.ini), but cannot target specific window for specific URL. That's the obstacle.

So are you trying to do this in firefox or dwb??

Dwb has dwbremote which makes opening new urls in any specified window trivially easy.  Once the 5 windows are placed and you know their ids, then dwbremote could do this well.  But the downside is I see no way to specify resource class/names for new dwb instances.

Firefox does allow for the specification of resource name/class pretty easily, but does not have a "remote" program - xulrunner may do this but I've never used it before.

But my question still stands: do the browser windows need to be open first and updated with new urls once open, or will a solution that opens five browser windows on five workspaces be sufficient?


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

Offline

#9 2014-07-28 21:52:21

nexutix
Member
Registered: 2014-07-28
Posts: 8

Re: [Solved] How to open n different URLs in n different browser windows

Trilby wrote:

But my question still stands: do the browser windows need to be open first and updated with new urls once open, or will a solution that opens five browser windows on five workspaces be sufficient?

i3-wm can easily handle initial opening of windows. Then I will just be pushing URLs intermittently in bursts to all these windows, which will load new URL in same buffer/tab without invoking new tabs.

I think I can hookup dwbremote using name of window; but not sure about class. I have read manpage, there doesn't seem to be any option relating to setting custom class. Thanks for hinting about dwbremote!

So I dug into dwb source files and found this bit:

dwb_application_class_init (DwbApplicationClass *class)
{
    GApplicationClass *app_class = G_APPLICATION_CLASS (class);

    app_class->run_mainloop = dwb_application_main;
    app_class->quit_mainloop = dwb_application_main_quit;
    app_class->local_command_line = dwb_application_local_command_line;
    app_class->command_line = dwb_application_command_line;
}

I am not sure; because I only know python and never learnt C. Maybe I might be able to set custom class for dwb and compile multiple times to execute multiple distances; but for now, I am sticking with conkeror. Marking this as solved.

Last edited by nexutix (2014-07-28 22:04:17)

Offline

#10 2014-07-29 00:51:11

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

Re: [Solved] How to open n different URLs in n different browser windows

Having many compiled versions would be very odd - just add a command line parameter to specify a resource class.  This would be trivially easy to do ... but that is not the right code block.  Let me take a look ...

The minimal edit would be adding one line to dwb.c at line 4694 in dwb_init_gui (in current git code):

     /* Window */
     if (dwb.gui.wid == 0)
         dwb.gui.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     else
         dwb.gui.window = gtk_plug_new(dwb.gui.wid);

     gtk_widget_set_name(dwb.gui.window, dwb.misc.name);
+    gtk_window_set_wmclass(dwb.gui.window, getenv("NEWDWB"), "DWB");
     /* Icon */
     GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data(icon);
     gtk_window_set_icon(GTK_WINDOW(dwb.gui.window), icon_pixbuf);

This would require that an enviornment variable be set for each new instance:

NEWDWB="ForWorkspace1" dwb
NEWDWB="ForWorkspace2" dwb
NEWDWB="ForWorkspace3" dwb
...

For a more robust solution, you could also add a new command line parameter to set a variable rather than grabbing one from the environment.  I'll link to this post from the dwb thread and see if Portix would add this option upstream.

Last edited by Trilby (2014-07-29 01:01:57)


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

Offline

#11 2014-07-29 03:33:10

nexutix
Member
Registered: 2014-07-28
Posts: 8

Re: [Solved] How to open n different URLs in n different browser windows

Trilby wrote:

The minimal edit would be adding one line to dwb.c at line 4694 in dwb_init_gui (in current git code)...

I got it to work by modifying second class value like this: (For i3 to detect)

gtk_window_set_wmclass(dwb.gui.window, "Dwb", getenv("DWBCLASS"));

I have compared both setups (conkeror and dwb) for some hours and here are some observations:

1. dwb beats conkeror in terms of RAM usage. (2.1G with conkeror, 1.3 G with dwb)
2. page load times of conkeror are better than dwb in almost all cases
3. My god, some sites just look hideous in dwb: http://i.imgur.com/o6Digsh.png
4. For current version (Version : 2014.07.28); some pages are really slowly loading (never happened this with conkeror on same network).
5. dwb just gives up on some pages: http://i.imgur.com/5Xqwn0D.png

Anyway, thanks Trilby for making me explore choices!

Last edited by nexutix (2014-07-29 03:34:19)

Offline

Board footer

Powered by FluxBB