--- webbrowser.py.orig 2016-08-13 20:58:43.000000000 +0300 +++ webbrowser.py 2016-10-09 08:37:35.821389166 +0300 @@ -272,6 +272,7 @@ args = [arg.replace("%s", url).replace("%action", action) for arg in self.remote_args] + args = [arg for arg in args if arg] success = self._invoke(args, True, autoraise) if not success: # remote invocation failed, try straight way @@ -294,6 +295,30 @@ Netscape = Mozilla +class NewFirefox(Mozilla): + """Launcher class for Mozilla Firefox browsers with versions >= 36.0""" + + raise_opts = None + remote_args = ['%action', '%s'] + remote_action = "" + remote_action_newwin = "-new-window" + remote_action_newtab = "-new-tab" + + +def _get_firefox_major_version(): + try: + firefox_ver = subprocess.check_output(['firefox', '--version'], + stderr=subprocess.STDOUT) + except (OSError, subprocess.CalledProcessError): + return -1 + + # firefox_ver is something like "Mozilla Firefox 40.0" + try: + return int(firefox_ver.split()[-1].split(b'.')[0]) + except: + return -1 + + class Galeon(UnixBrowser): """Launcher class for Galeon/Epiphany browsers.""" @@ -478,7 +503,11 @@ "iceweasel", "iceape", "seamonkey", "mozilla", "netscape"): if _iscommand(browser): - register(browser, None, Mozilla(browser)) + if browser == "firefox" and _get_firefox_major_version() >= 36: + klass = NewFirefox + else: + klass = Mozilla + register(browser, None, klass(browser)) # Konqueror/kfm, the KDE browser. if _iscommand("kfm"):