You are not logged in.
My scenario is simple - I have two browser profiles, personal and work. Now I have two sources I get urls.
My goal is to have a way to open urls from one source (let's say Slack) with personal profile and from another one (e.g. Teams) with work profile.
I already created proper entry in /usr/share/applications which runs script inside my bin dir and it works fine but ofc opens all links with the same profile.
I see three ways of solving that:
1) I heart somewhere in past that I can use shift-click/ctrl-click which could use different applications than just click, however cannot find any information what happens internally then and how to use that.
2) Use some global variable which I could change with some shortcut and use it in script that opens the browser. Probably could write it to some file with echo with script and run it with rofi, but not sure is it elegant.
3) Somehow tell the OS the context where I clicked the link - if it came from Slack use application A, if Teams use B.
I am using bspwm and sxhkd under X11
Could you guide me a bit what directions would you go if you were me and provide details where should I dig further?
Last edited by kosciej16 (2023-03-21 12:51:54)
Offline
This really depends on what Slack and Teams do. I'm pretty sure they both use xdg-open to handle urls, in which case exporting the environment variable BROWSER (into the environment that Slack or Teams are launched from) should do it.
I say 'should' as xdg-open and the related xdg-utils are notorious for failing to do what the documention says they should. However, creating a drop-in replacement that actually honors the setting of BROWSER should be trivial if needed (or look into one of the many ready made existing replacements for the dumpster-fire that is xdg-open - I recall mimeo being a popular one, though I have no experience with it).
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thank you for a quick answer!
I played last hour with xdg-open and to be honest it doesn't listen me. The BROWSER variable is not respected at all.
➜ ~ xdg-settings get default-web-browser
qute.desktop
export BROWSER=google-chrome && xdg-open https://www.google.com # always opens with qute.desktop
I tried milions values for BROWSER, made sure proper .desktop file exists and nothing. The only way to change the browser is with
unset BROWSER
xdg-settings set default-web-browser firefox.desktop
Last edited by kosciej16 (2023-03-21 14:48:58)
Offline
Hence my second paragraph. I'd just ditch xdg-open - it's ridiculously complex and error-prone. Use one of the replacements which will almost certainly respect the BROWSER variable out-of-the-box.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline