Page 1 of 1

Browser Installer - choose your browser

Posted: Fri 16 Apr 2010, 12:22
by sc0ttman
This is for puppy 4.2.x and maybe 4.3.x

01micko released the original here.
I have added a few more browsers, and made it work (for me, at least) in 4.2

I've added '-pa' to the end of the filename as it will be used in Puppy Arcade 8

I have created a few new .pet packages of browsers,
adding a few libs and menu entries so they work 'out of the box' in 4.2..

The browsers I (and others) packaged are hosted at ppm.scottjarvis.com

To customise, edit the the config file, /root/.browser-links.config.. and the main file /usr/sbin/browser-installer

This is primarily designed for my next project, and is offered as is...

NOTE: Google Chrome needs work, before it works

All credit goes to 01micko for the original!!!!!!

Posted: Fri 16 Apr 2010, 14:08
by sc0ttman
Possible improvements, that I wanna make:

- re-build the defaultbrowser file after each browser is installed, with the relevant command (help me please!)

Posted: Fri 16 Apr 2010, 14:57
by WarMocK
sc0ttman,
you could use sed:

Code: Select all

cp /usr/local/bin/defaultbrowser /tmp/defaultbrowser
sed -e 's/seamonkey/firefox/g' /tmp/defaultbrowser > /usr/local/bin/defaultbrowser
Do this for opera, chrome etc as well, or use case to create a clause for every browser selected. Personally I would do it a different way, but that's because I threw the original default scripts out and replaced them with new ones that start the program listed in a separate config file in my home directory. ;-)

Posted: Fri 16 Apr 2010, 19:30
by sc0ttman
WarMocK wrote:sc0ttman,
you could use sed:

Code: Select all

cp /usr/local/bin/defaultbrowser /tmp/defaultbrowser
sed -e 's/seamonkey/firefox/g' /tmp/defaultbrowser > /usr/local/bin/defaultbrowser
Do this for opera, chrome etc as well, or use case to create a clause for every browser selected.
Thanks a lot, that helps me a little.. However...

While I need to be able to change the final line in defaultbrowser, (as it has the command to be replaced), I will not know what value that line contains, so cannot replace one fixed string with another..

I think the easy way to do this is simply replace the last line of the file, with a new string... How do I do this?

I read you can't combine a sed 'd' and 'a' as the 'd' command ends things...
So I don't know how I would do this.. Help, anyone?

Posted: Fri 16 Apr 2010, 20:47
by WarMocK
After reading out what browser was chosen:

Code: Select all

echo "#!/bin/sh" > /tmp/browserchange
echo "sed -e 's/seamonkey/$BROWSER/g' /tmp/defaultbrowser > /usr/local/bin/defaultbrowser" >> /tmp/browserchange
chmod +x /tmp/browserchange
sh /tmp/browserchange
That'll create a script which replaces the standard entry for the browser with the variable $BROWSER (aka what was selected) in /tmp, then makes it executable and runs it, modifying defaultbrowser.

Posted: Fri 16 Apr 2010, 20:57
by sc0ttman
WarMocK wrote:After reading out what browser was chosen:

Code: Select all

echo "#!/bin/sh" > /tmp/browserchange
echo "sed -e 's/seamonkey/$BROWSER/g' /tmp/defaultbrowser > /usr/local/bin/defaultbrowser" >> /tmp/browserchange
chmod +x /tmp/browserchange
sh /tmp/browserchange
That'll create a script which replaces the standard entry for the browser with the variable $BROWSER (aka what was selected) in /tmp, then makes it executable and runs it, modifying defaultbrowser.
Thanks again for your quick response... And, while I'm a total novice at this stuff, I think this won't work for me..

This is because I cannot assume the default browser is Seamonkey..

When replacing the command in defaultbrowser that actually executes the browser, I cannot assume this line contains the string 'seamonkey'..

I'm sure the solution is very simple, but I certainly don't know it!!! :roll:

Posted: Fri 16 Apr 2010, 21:26
by WarMocK
*phew* It's been a while since I threw the original files out. Mind posting the code from defaultbrowser in here again for me? ;-)

Posted: Fri 16 Apr 2010, 21:33
by sc0ttman
WarMocK wrote:*phew* It's been a while since I threw the original files out. Mind posting the code from defaultbrowser in here again for me? ;-)
It could be:

Code: Select all

#!/bin/sh
exec mozstart "$@"
Or:

Code: Select all

#!/bin/sh
exec firefox-bin "$@"
etc..

But the last line should always start with 'exec', and end with '"$@"'

I think the fastest and most efficient way to replace the command after 'exec' will be to totally replace the last line with another string (which can be hard coded) ..

Or ideally, replace only the stuff between 'exec' and '"$@"' but I'm too dumb to do it..

Posted: Fri 16 Apr 2010, 21:52
by WarMocK

Code: Select all

OLDBROWSER="`cat defaultbroser | grep exec`"
Use this, then replace $OLDBROWSER with "exec $BROWSER "$@"" using sed.

Posted: Fri 16 Apr 2010, 22:12
by sc0ttman
WarMocK wrote:

Code: Select all

OLDBROWSER="`cat defaultbroser | grep exec`"
Use this, then replace $OLDBROWSER with "exec $BROWSER "$@"" using sed.
Cheers.. Just realised this won't work for 'non-standard' defaultbrowser files.. (PuppyBrowser...)

I am gonna adapt your code and just delete everything after #!/bin/sh and append exec $BROWSER "$@" - as this command is the standard...

Thanks for your help. :D

Posted: Sat 17 Apr 2010, 21:15
by 01micko
Hi sc0ttman

Nice job!

One thing.. put a comment at the top of the script saying "modded by sc0ttman on such and such date for whatever reason"
And probably should put a link to the gpl lisense and saying software is provided "as is", no warranty in the comment. Er, I should have done that!

I can't take all the credit.. :)

Cheers

Posted: Sat 17 Apr 2010, 22:12
by sc0ttman
Thanks 01micko...

I hope I'm not stepping on your toes, but I saw your work on this, and thought 'I gotta get me some of that.. for *my* next project..'

I'll add your suggestions, as a new tab, in the top row..

I'd like to add the following features/improvements as well:

- move browser packages (used in this app) from http://ppm.scottjarvis.com to public puppy server (anyone??...)
- Automatic re-creation of defaultbrowser and defaulthtmlviewer files
- Get email, flash and java links working

As a side note, I've often thought someone (with better skills than me) should write a function that can be used in the terminal, which easily updates the default*** files with the new value exec $APP "$@"

Something like:

Code: Select all

update-default [browser|htmlviewer|paint|etc] [command]
Examples:

Code: Select all

update-default -browser opera
update-default -spreadsheet calc
These would produce the lines exec opera "$@" in defaultbrowser and exec calc "$@" in defaultspreadsheet

Just a thought... Which should probably be posted elsewhere...

Posted: Sat 17 Apr 2010, 22:28
by 01micko
I think pizzasgood has already made the default changer you are looking for...

If it's not on your system then I think it may be in DuDE by zigbert.

Hey, it's open source, everything is fair game.

Cheers

Posted: Sat 17 Apr 2010, 23:22
by sc0ttman
01micko wrote:I think pizzasgood has already made the default changer you are looking for...

Cheers
I saw that, and will test it out, but wondered if a simple commandline version was available?

I'd also like to have the browser-installer run fixmenus after installing the browser... but only if the browser was installed..

anyone know the best way to do this?
I'll have a go myself anyway.. but just asking

after petget finishes, i could check for the existence of certain file(s), and then run fixmenus if they were found...

default app changer

Posted: Sun 18 Apr 2010, 14:44
by sc0ttman
sc0ttman wrote:As a side note, I've often thought someone (with better skills than me) should write a function that can be used in the terminal, which easily updates the default*** files with the new value exec $APP "$@"
01micko wrote:I think pizzasgood has already made the default changer you are looking for...
I saw that, and will test it out, but wondered if a simple commandline version was available?
Well, now it is.. I created a simple script that changes the default*** to the command you enter

DEFAULT APP CHANGER is here

Posted: Mon 17 May 2010, 21:34
by sc0ttman
updated... see main post