Open Marxsal opened 5 years ago
I have done some testing on this. You can get very close to a universal method for near all cases, including default and non-default browsers. I carry on working on that and see if I can describe a common path.
Ok. I'm assigning you for at least the research stage. You know, I really need to get a cool avatar like you have.
Jermolene made it for me. Thomas tweaked it.
IF we use [wikis] to determine (sensible) what gets auto-started there IS a problem.
Because we also let files like "C:\users\polly\note\my-estranged-beak.db" be recorded as wikis (for parroting).
What happens with that on "Start-Process"?
Perhaps all non-wiki files need go under [otherfiles]?
Because we also let files like "C:\users\polly\note\my-estranged-beak.db" be recorded as wikis (for parroting).
What happens with that on "Start-Process"?
Just launch .htm/.html files, perhaps?
@Marxsal wanted to update you on where I got to ...
BROWSER LAUNCH LOGIC & CODE
There are several ways to open browsers and web pages in PowerShell. I tested with 5 variant methods on 10 Browsers. After testing, the simplest, reliable, method looks like it is to open ONE $uri at a time (i.e. not all at once) using "Start-Process". So ...
IF user DEFINED a "browser=Path/browser.exe" in settings.ini then the command is ...
Start-Process $browser "$uri"
ELSE the DEFAULT browser is triggered when
"browser="
via ...
Start-Process "$uri"
IF setting "browser=" does not exist then menu option
"L - Launch Wiki"
would be hidden
A downside (inevitable) is we don't know how users will have configured their browsers. The method might open one instance of browser, or several. I might add a note in Docs about that. Though its not a Polly issue per se.
The "Start-Process" method worked well, at least on Windows. As simple as (fingers crossed) ...
if(-not[string]::IsNullOrEmpty($browser)){
# defined browser
Start-Process $browser "$uri"
}else{
# default browser
Start-Process "$uri"
}
But needs testing on Linux / MacOS
Another method (backwards compatible) I'm looked into would be to assemble a "raw command line" when "browser=something" is set. This would allow the user to ALSO specify more details in the command ...
browser="C:/portable/apps/ev/evolution.exe -profile myPollyProfile -no-remote"
activated via ...
& $browser $uri
That needs more work & research. And vocal demand from the 2.5 users :-)
@Marxsal: Just launch .htm/.html files, perhaps?
Okay. Best in filter in run-loop?
Let me know if this makes sense & is helpful. Also do you want the test code putting somewhere?
TT
browser="C:/portable/apps/ev/evolution.exe -profile myPollyProfile -no-remote"
activated via ...
& $browser $uri
That works as long as the uri goes at the end. Does it with all browsers?
Okay. Best in filter in run-loop?
Unless the poor little loop's logic becomes impossible to follow, in which case we put everything in it's own function, possible in a separate library file.
Let me know if this makes sense & is helpful.
Yes, it is. But it's going to need to be refined. If there's no defined browser on linux, then I think we have to check for a browser. There's a default browser link, x-www.browser which works in debian/ubuntu. We can check for it's existence (I think). If it exists, we can launch. If not, we have to say "Sorry Dave, I can't do that" or something.
Checking for the existence of software on Linux is done via the "which" command. All the Linux commands appear to work in PS, as long as they don't conflict with PS aliases. What I don't know is how to fetch and use the results of a command like
which editor
TIL that Linux thinks my default browser is Chrome. I didn't even know I had chrome on the machine.
After consultation, I think we're going to need linux users to tell us what browser they use. We can recommend they look up the name from their desktop or application launcher. The name may not be intuitive unless they look it up from their desktop. For instance, "chrome" isn't "chrome", it's "google-chromium-stable".
On Windows the process of launch was easy once you hone it and I derived a good method, I think.
The Linux thing, well, its practically out of my possibility.
@Marxsal: That works as long as the uri goes at the end. Does it with all browsers?
Yes. That "&" initiation was experimental but works. The MAIN issue on Windows is launching of browsers by exe address DIFFERS from DEFAULT activation. Default activation is conservative & minimal. Follow its rules and all browsers work.
I'm beginning to grasp Linux has no defaults?? Right?
it's going to need to be refined. If there's no defined browser on linux, then I think we have to check for a browser.
Okay (groan).
I tried to find info on capturing "which" output on PS6, but there is scarce info as yet on o/s variants.
Perhaps it needs to be piped into capture? "Which" does have output.
Rethinking. Maybe for Linux, and by extension, Mac, users, we can just create a starter settings.ini with lots of embedded comments. Linux people tend to have lots of experience with tweaking settings. Unless you bought a machine with Linux already on it, you probably had to do a fair amount of tweaking just to get where you are. And we don't even know if Mac users are going to be receptive to PS.
Rethinking. Maybe for Linux, and by extension, Mac, users, we can just create a starter settings.ini with lots of embedded comments.
Okay. That reinforces idea that actually there is a "setup" process on first use.
Would you want to add an item for "editor =" ?
Would you want to add an item for "editor =" ?
Yes, that would make sense. Most die-hard Linux fans are also veterans of the great Emacs/Vi wars, and can tell 15 you different reasons their choice is best. Forty years on, and the scars remain.
It looks like Mac does have a standard (TextEdit) text editor built-in, so you could insert that automatically for $isMacOs (after finding out how to invoke it).
It should be relatively easy to do mildly differing setup process by platform. I got the logic laid out formally. It will take some days yet to code it. As soon as I have a workable test I'll let you know. I'm very aware it needs early testing on Linux.
The problem is that there is likely no universal, reliable way to launch using any browser other than the default browser (which may not be the browser and profile that the user regularly wants).