LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Changed html file assoc. in KDE, but have issues (https://www.linuxquestions.org/questions/linux-software-2/changed-html-file-assoc-in-kde-but-have-issues-158616/)

servo_fan 03-16-2004 05:20 PM

Changed html file assoc. in KDE, but have issues (Firefox Profiles)
 
I've changed the html association in KDE, (3.1.4 in SuSE 9), to open Firefox, (firefox is installed in my home directory). If I click on an html file in Konquerer it starts Firefox and displays the html page. However, if Firefox is still open and I click on another html file in Konquerer, Firefox tries to open another instance of itself and it prompts me for a profile to use. If I choose my default profile, it errors, saying it is already in use.

Does anyone know of a way to prevent this from happening? Thanks.

servo_fan 03-17-2004 01:15 PM

I've narrowed it down a bit, it has something to do with adding a -remote switch to the firefox command, (http://www.mozilla.org/unix/remote.html).

When I click on an html file I can now get Firefox to open a new window or tab, but it does not display the file I've clicked on, it just opens a blank window, (or tab).

So part of the problem is solved. I would appreciate any insight into the remaining problem. Thanks.

servo_fan 03-17-2004 01:36 PM

Changed html file assoc. in KDE, but have an issue (Firefox profiles)
 
I found this in a newsgroup. The person who posted it could not site the original post or author. Here it is and it works well.

Quote:

I think your problem is that you're running mozilla-bin twice or more
and you need your apps to send their browser request to mozilla.sh. The
mozilla.sh is a dumb little script that says "open an instance of
mozilla-bin if one is not running, otherwise open a new window (or tab)"

Here's what my script looks like, it's for firefox, but you'll get the
concept:
#!/bin/sh
MOZILLA="/usr/bin/mozilla-firefox"
if $MOZILLA -remote "ping()" 2>/dev/null
then
echo "Mozilla already launch"
location=",new-tab"
exec $MOZILLA -remote "openURL($1$location)"
else
exec $MOZILLA "$@"
fi
exit 1

you could copy this, change the appropriate names and locations, save as
mozilla-remote in the /usr/bin directory (make it executable ). and
then tell KDE or whatever environment you're using to use
"mozilla-remote.sh" as your default browser.

questone 03-26-2004 07:36 PM

servo_fan,

I ran the script that you posted above. And a couple aproblems still there.
1. If I don't have Firefox open and I am in my mail and click a url then FIrefox doesn't open.
2. If Firefox is open and I click a url in my mail then Firefox opens a new tab but not the url.

Thanks for the script. Any suggestion?

servo_fan 03-26-2004 11:25 PM

I assume that you've already changed the html association in KDE or whatever to use this script, correct? And did you change the path locations to match where you have Firefox installed and make it executable? I did not have any issues with the script myself.

Actually, the only way I've tested it is by clicking on a .html file from my local file system, I have not tested the script by clicking on an url from an email - although in theory I think it should work.

Let me know how it goes.

Kovacs 03-26-2004 11:53 PM

Here's a slightly different variation that works by getting the process id:

#! /bin/sh

# find pid of running moz, if any, for current user
PID=`ps -ef | grep $USER | grep firefox-bin |\
grep -v "grep" | awk '{print $2}'`

# if moz is not running, start normally
if [ $PID="" ]; then
/path/to/firefox $1;

# otherwise, open url in a new window
else
/path/to/firefox -remote "openurl($1,new-tab)";
fi

questone 03-27-2004 11:27 AM

Ok now Im getting a little closer. The first scrip would open a new tab but not open fire fox if it was not already open. The second would open firefox if it was not open but wouldn't open a new tab. So I combined them like this:

-----------------------------------------------------------------------------------
#!/bin/sh

MOZILLA="/home/steve/.firefox/firefox"

# find pid of running moz, if any, for current user
PID=`ps -ef | grep $USER | grep firefox-bin |\
grep -v "grep" | awk '{print $2}'`

# if moz is not running, start normally
if [ $PID="" ]; then
/home/steve/.firefox/firefox $1;
fi

if $MOZILLA -remote "ping()" 2>/dev/null
then
echo "Mozilla already launch"
location=",new-tab"
exec $MOZILLA -remote "openURL($1$location)"
else
exec $MOZILLA "$@"
fi
exit 1
---------------------------------------------------------------------------------------
With this script if I click a url in my mail it will open fire fox if not already running and if it is running it opens a new tab. However the url location doesn't open in either instance. If fie fox is not running then I go to my home page and if it is I get a blank tab. I'll keep playing with it but I assume that the line:
exec $MOZILLA -remote "openURL($1$location)"
supposed to do this. But Im not sure as I really have no Idea what Im doing. Just trial and error. I edit the script save and click a url and see what happens. Thanks for any direction.

questone

Kovacs 03-27-2004 06:08 PM

Um the one I posted should be opening things in a new tab always, you have to select "always show tabs even if only one document is open" in the firefox options.

vi0lat0r 03-27-2004 07:42 PM

How about you set the file extension to:

soundwrapper /usr/bin/mozffremote

That works perfect here. :-)

fbs95842 04-03-2004 09:00 PM

Quote:

Originally posted by Kovacs
Um the one I posted should be opening things in a new tab always, you have to select "always show tabs even if only one document is open" in the firefox options.
Kovacs' solution worked perfectly for me. Thank you.

questone 04-06-2004 08:32 PM

This script does work as it is said to work here. ie: if I have a link on my desktop that I double click it opens in firefox as intented, but still doesn't wotk from Thunderbird when I click on a link in my e-mail. I really don't have any links on my desktop so... I don't know what I need to add to the script to get it to, umm? "export" the link that I am clicking on to firefox. Clicking on the link in TB does open a new tab or the browser respectively but firefox seems to have no Idea at that point where I need to go. The odd thing is in my RSS client if I click on a link to a torrent file (I have a helper app setup in FF to open .tor files) a new tab opens in FF and my helper app opens and and starts running witht the .tor file. So I take this to meant that the url is being seen by FF but for some reason it is not opening in the tab. I am so lost. I know where I want to go I can see the destination from where I stand , but I don't seem to be able to drive very well I need some instruction.
Thanks
quest

allofitsik 05-05-2004 10:21 PM

Sorry for dragging up an old thread. I used the above script to be able to open links in already open browser in Gnome. however, the problem i have encountered, while not serious as this setup is only one of many for me, is that if firefox is open on a different screen than on the one that i click the link on. I assume that it would work if i were using Xinerama, however, xinerama screws with matlab.
if there is a way to get it to work, it would be much appreciated...

-ta.


All times are GMT -5. The time now is 06:13 PM.