bfontaine
bfontaine

Reputation: 19826

With Ruby on Ubuntu, how can I check what is the default browser?

I’m making a program with Ruby where I need to know the default browser of the user (actually, I want to know if his/her default browser is Chrome or Chromium (and which one)). How can I do that?

Upvotes: 1

Views: 79

Answers (1)

Nick Kugaevsky
Nick Kugaevsky

Reputation: 2945

You can find out default user browser with bash command, and then check out inclusion of chrome or chromium substring. Something like this.

1.9.3p194 :001 > mimelist = `cat ~/.local/share/applications/mimeapps.list | grep text/html`
 => "text/html=google-chrome.desktop\n"
1.9.3p194 :004 > mimelist.include?('chrome')
 => true 
1.9.3p194 :005 > mimelist.include?('chromium')
 => false

Upvotes: 1

Related Questions