reddit / emacs

Please, elfeed etc., open the URL in the browser window sharing a workspace with the current Emacs frame!

[deleted] · 2022-12-21 14:12
[deleted]
phr46 · 2022-12-21 16:48
I use dwm, and I would handle this by modifying it to dump the information I need to a file in a fixed location every time I switch workspace. Then in Emacs I could implement a browse-url-browser-function to read that file and dig the browser process. That would avoid Emacs and dwm having to interact directly. What I don't know is how the browser interaction could work, how would you specify to the browser to open a URL in a specific window. No ideas there.
chmouelb · 2022-12-21 18:21
unless you are doing some crazy xorg acrobatics with xdotools and other tools like (which mean no wayland if you are into it) i don't think there is a way to ask firefox (or others) to open this url in that browser window... but yeah with something like i3 and xdotools you can find out which ws the current emacs frame is on, if there is a browser windows belonging to that ws and the use xdotools to target it and open a new tab with the url.... not super confident this would be rock solid tho... good luck
[deleted] · 2022-12-21 18:46
[deleted]
vaxdar · 2022-12-22 00:09
This would be a really useful thing to be able to manage generally, not just with emacs. Opening a few links and then realizing that the visible browser window was not the last one focused and wondering where those tabs just went is never fun.
[deleted] · 2022-12-22 04:55
[deleted]
vaxdar · 2022-12-22 07:48
I think the problem is that (as /u/phr46 said in another comment) you have to tell the *browser* which window to open in, so the browser needs an option to specify the window. Finding the visible window is the relatively easy part, I think.
phr46 · 2022-12-22 13:30
Based on what u/chmouelb said, I can think of a hack. Instead of telling the browser the right window, you could change the window manager to quickly switch to the window of the browser and back, when you are trying to open a link. That will force the window in the same workspace to be the last one used for the browser, so just passing the URL to the browser executable should work. But then you need Emacs and the window manager to interact more directly. You need to trigger this switch somehow when Emacs opens a link.
vaxdar · 2022-12-22 16:32
Yes, just having a script named `firefox` before the actual `firefox` in your `$PATH`, so it wraps the original, should work. I had been thinking of just always focusing a visible browser when switching workspaces, but that would be bad for a couple of reasons. Doing it when opening a link is probably better, except for the times when you *wanted* the link to open on a different workspace. That might be rare, though.