end
def launch_brwoser(url)
- puts "Access follwoing URL to get auth code;\n#{url}"
- %w(/usr/bin/xdg-open /usr/bin/X11/xdg-open /usr/local/bin/xdg-open
- /usr/bin/x-www-browser /usr/bin/firefox /usr/local/bin/firefox
- ).each do |bin|
- File.executable?(bin) or next
- exec(bin, url) if fork.nil?
- return
+ puts "Access following URL to get auth code;\n#{url}"
+ if ENV['DISPLAY']
+ %w(/usr/bin/xdg-open /usr/bin/X11/xdg-open /usr/local/bin/xdg-open
+ /usr/bin/x-www-browser /usr/bin/firefox /usr/local/bin/firefox
+ ).each do |bin|
+ File.executable?(bin) or next
+ exec(bin, url) if fork.nil?
+ return
+ end
end
case RUBY_PLATFORM
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
- exec("start #{url}") if fork.nil?
+ spawn("start #{url.gsub(/&/, '^&')}")
when /darwin|mac os/
exec("/usr/bin/open", url) if fork.nil?
end