Skip to content

Instantly share code, notes, and snippets.

@dobesv
Created March 16, 2023 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dobesv/980faee42f41e066110d1afce3ef26b1 to your computer and use it in GitHub Desktop.
Save dobesv/980faee42f41e066110d1afce3ef26b1 to your computer and use it in GitHub Desktop.
Home-made Browser Picker for Linux

How to use this

Some ability to edit shell scripts is required, this is not something that is super user friendly.

  1. Download browser-chooser as ~/.local/bin/browser-chooser
  2. Edit the script to customize the script to suit your needs. You can figure out the name of a chrome profile by going to chrome://version in Chrome and looking at the end of the "Profile Path"
  3. Download the desktop file into ~/.local/share/applications
  4. Add ~/.local/bin to your PATH if it is not in there already
  5. Log out and back in to update PATH for the window manager if necessary
  6. Should be able to run browser-chooser from the command line
  7. browser-chooser should now show up in the "start menu" to launch
  8. It should show up as an option to set as your default browser in settings, select it there to use it
#!/usr/bin/env bash
# Install into ~/.local/bin/browser-chooser
case "$1" in
*salesforce*|*basecamp* )
CHOICE=chrome/work
;;
*youtube* )
CHOICE=chrome/personal
;;
* )
echo "No preset for URL, prompting user"
CHOICE=$(zenity --title="Choose Browser for $URL" --width=800 --height=600 --timeout=300 \
--list --column Key --column Browser --column Profile \
"chrome/personal" "Google Chrome" "you@home.com" \
"chrome/work" "Google Chrome" "you@work.com" \
"chrome/guest" "Google Chrome" "Guest Profile" \
"chrome/incognito" "Google Chrome" "Incognito" \
"firefox/default" "Firefox" "Default" \
"chromium/default" "Chromium" "Default"
)
if [[ "${CHOICE}" = "" ]] ; then
echo User did not select a browser, exiting
exit 0
fi
echo User selected ${CHOICE}
;;
esac
case $CHOICE in
chrome/personal )
google-chrome '--profile-directory=Profile 1' "$@" & disown
;;
chrome/work )
google-chrome '--profile-directory=Default' "$@" & disown
;;
chrome/guest )
google-chrome '--profile-directory=Guest Profile' "$@" & disown
;;
chrome/incognito )
google-chrome --incognito "$@" & disown
;;
firefox )
firefox "$@" & disown
;;
chromium )
chromium "$@" & disown
;;
esac
[Desktop Entry]
Name=Browser Chooser
GenericName=Browser Chooser
Comment=Choose what browser to use for specific links
Categories=Network;
Exec=browser-chooser %u
Type=Application
MimeType=x-scheme-handler/unknown;x-scheme-handler/about;text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment