Xonotic Forums
[SOLVED] How to launch from Firefox? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Help & Troubleshooting (https://forums.xonotic.org/forumdisplay.php?fid=4)
+--- Thread: [SOLVED] How to launch from Firefox? (/showthread.php?tid=4904)



How to launch from Firefox? - Vigil - 05-10-2014

I see a server listing here, but when I click on a xonotic:// link, Firefox tells me the protocol is unrecognised. I added the protocol according to this page, and chose xonotic-linux-glx.sh as the application to launch. Sure enough, it launches, but not at the server I selected. I tried the gconftool-2 suggestion, still no deal.

So, how can I click a xonotic link in Firefox and have Xonotic launch me into that game? I installed Xonotic by downloading it and unpacking it manually, ie. not by a package manager.

Incidentally, the servers listed on that page don't all (any?) appear in the in-game server list. I wonder if people get the wrong impression of player numbers because of that…


RE: How to launch from Firefox? - Mr. Bougo - 05-10-2014

You should pass the server address to the "connect" command. Your full command should be
Code:
xonotic-linux-glx.sh +connect example.com:26000
, instead of
Code:
xonotic-linux-glx.sh example.com:26000
as I assume you're doing now.

As for the servers appearing or not, are you sure you're not filtering in your in-game list? The list of server should be exactly the same, because the server listing webpage runs on the master server from which the in-game server list fetches its data.


RE: How to launch from Firefox? - Vigil - 05-10-2014

Firefox's application chooser dialog only allows to select binaries. How would I pass it arguments? And would I substitute the address for "%s"?


RE: How to launch from Firefox? - Mr. Bougo - 05-10-2014

Right, the gconf thing might be able to, but Firefox' builtin handler does not. What distro do you use? Do you use GNOME?

Anyway, to use the builtin firefox handler instead of GNOME's, you'll have to create a script that takes the first argument and passes it to xonotic:
Create a directory "bin" in your home directory, and put the following in the file xonotic-connect:
Code:
#!/bin/sh
"$HOME/whatever/xonotic-linux-glx.sh" +connect "$@"
where you should replace "whatever" with whatever path your xonotic-linux-glx.sh is in your home directory.

Then, make that file executable and use that as the url handler in Firefox.


RE: How to launch from Firefox? - Vigil - 05-10-2014

I'm not using a desktop environment, just a window manager. Although I do have some KDE and Gnome stuff installed, I'm not using it on 'the desktop'.

I created the script like you said and it worked with a couple of modifications:

Code:
#!/bin/bash

/home/vigil/Xonotic/xonotic-linux32-glx -basedir /home/vigil/Xonotic +connect "${1:10}"

-basedir was required, and ${1:10} strips away "xonotic://" from the address that gets passed to +connect.

Just had a couple of online games. Cool :-)

The servers not appearing was a result of my firewall.


RE: How to launch from Firefox? - Mr. Bougo - 05-10-2014

Cool people don't need DEs Wink

-basedir is required because you used the path to the binary file, not the shell script! I think it's better to drop the basedir and use the script instead, which takes care of setting the environment just right.

I didn't know firefox would not strip away the prefix. Makes sense, though. Here's something a little more clever that you can do to strip it yourself:
Code:
sv=${1#xonotic://};
shift;

"blablabla/xonotic.sh" +connect "$sv" "$@"

It adds a little more flexibility in the sense that you can omit the xonotic:// and it will work just fine, and you can pass it extra parameters as well like xonotic-connect.sh 1.2.3.4:26000 +vid_fullscreen 0

This is of course completely optional and will behave the same as your current script.


RE: How to launch from Firefox? - Vigil - 05-10-2014

Ah yes, I didn't think I'd need to call it with any other options. Best to have the flexibility.