Land #2148, prefer xdg-open over sensible-browser

bug/bundler_fix
Tod Beardsley 2013-07-23 14:39:18 -05:00
commit 5736f65d4e
1 changed files with 5 additions and 6 deletions

View File

@ -131,9 +131,11 @@ def self.open_browser(url='http://metasploit.com/')
# Search through the PATH variable (if it exists) and chose a browser
# We are making an assumption about the nature of "PATH" so tread lightly
if defined? ENV['PATH']
# "sensible-browser" opens the "default" browser in Ubuntu and others, so try that first
# but also provide fallbacks
['sensible-browser', 'firefox', 'opera', 'chromium-browser', 'konqueror'].each do |browser|
# "xdg-open" is more general than "sensible-browser" and can be useful for lots of
# file types -- text files, pcaps, or URLs. It's nearly always
# going to use the application the user is expecting. If we're not
# on something Debian-based, fall back to likely browsers.
['xdg-open', 'sensible-browser', 'firefox', 'firefox-bin', 'opera', 'konqueror', 'chromium-browser'].each do |browser|
ENV['PATH'].split(':').each do |path|
# Does the browser exists?
if File.exists?("#{path}/#{browser}")
@ -143,9 +145,6 @@ def self.open_browser(url='http://metasploit.com/')
end
end
end
# If nothing else worked, default to firefox
system("firefox #{url} &")
end
end