Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch in browser per ini list #18

Open
Marxsal opened this issue Aug 15, 2019 · 17 comments
Open

Launch in browser per ini list #18

Marxsal opened this issue Aug 15, 2019 · 17 comments
Assignees
Labels
todo A fully complete project would have this.

Comments

@Marxsal
Copy link
Owner

Marxsal commented Aug 15, 2019

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).

@Marxsal Marxsal added the todo A fully complete project would have this. label Aug 15, 2019
@TiddlyTweeter
Copy link
Collaborator

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.

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 15, 2019

Ok. I'm assigning you for at least the research stage. You know, I really need to get a cool avatar like you have.

@TiddlyTweeter
Copy link
Collaborator

Jermolene made it for me. Thomas tweaked it.

@TiddlyTweeter
Copy link
Collaborator

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]?

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 18, 2019

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?

@TiddlyTweeter
Copy link
Collaborator

@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

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 19, 2019

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?

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 19, 2019

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.

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 19, 2019

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".

@TiddlyTweeter
Copy link
Collaborator

TiddlyTweeter commented Aug 19, 2019

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.

@TiddlyTweeter
Copy link
Collaborator

@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.

@TiddlyTweeter
Copy link
Collaborator

I'm beginning to grasp Linux has no defaults?? Right?

@TiddlyTweeter
Copy link
Collaborator

TiddlyTweeter commented Aug 20, 2019

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.

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 20, 2019

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.

@TiddlyTweeter
Copy link
Collaborator

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 =" ?

@Marxsal
Copy link
Owner Author

Marxsal commented Aug 20, 2019

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).

@TiddlyTweeter
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
todo A fully complete project would have this.
Projects
None yet
Development

No branches or pull requests

2 participants