Skip to content

Instantly share code, notes, and snippets.

@nullvariable

nullvariable/README.md

Last active Oct 25, 2019
Embed
What would you like to do?
Simple script to select browser

Steps to get this working in Ubuntu 18.04

  • edit whichbrowser.sh as you see fit
    • handy way to see your Chrome profiles: cat ~/.config/google-chrome/Local\ State | jq .profile
  • copy whichbrowser.sh to /usr/local/bin/whichbrowser
  • copy whichbrowser.desktop to /usr/share/applications
  • edit /usr/share/applications/defaults.list to add whichbrowser.desktop to the same handlers as chrome/firefox
  • run sudo update-desktop-database
  • use Ubuntu settings -> Details -> Default Applications, to change default web browser to whichbrowser script
  • ???
  • profit
[Desktop Entry]
Version=1.0
Name=WhichBrowser
Exec=/usr/local/bin/whichbrowser %U
StartupNotify=true
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;image/webp;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
#!/bin/sh
ANSWER=$(zenity --list \
--title="Browser Picker" \
--radiolist \
--column "Pick" \
--column "Answer" \
FALSE "FireFox" \
FALSE "Chrome" \
FALSE "Chrome-AltProfile" \
FALSE "Chrome-Incognito" \
FALSE "FireFox-Private")
#echo "Answer: ${ANSWER}"
case $ANSWER in
FireFox)
/usr/bin/firefox $@
;;
Chrome)
/usr/bin/google-chrome-stable $@
;;
Chrome-AltProfile)
# use a different directory entirely with --user-data-dir=$HOME/<chrome-data-dir-name>
/usr/bin/google-chrome-stable --profile-directory="Profile 1" $@
;;
Chrome-Incognito)
/usr/bin/google-chrome-stable --incognito $@
;;
FireFox-Private)
/usr/bin/firefox --private-window $@
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment