Open browser based off of certain rules (like choosy for macOS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL=$1 | |
DOMAIN=$(echo "$URL" | awk -F[/:] '{print $4}') | |
## Domain starts with | |
if [[ $DOMAIN =~ $(echo ^\($(paste -sd'|' /home/your-user/.config/url-start.txt)\)$) ]]; then | |
chromium-browser "$URL" & disown | |
elif [[ $DOMAIN =~ $(echo ^\($(paste -sd'|' /home/your-user/.config/url-is.txt)\)$) ]]; then | |
firefox "$URL" & disown | |
else | |
firefox "$URL" & disown | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Name=Choosy | |
GenericName=Browser Chooser | |
Comment=Choose what browser to use for specific links | |
Categories=Network; | |
Exec=choosy %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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.mozilla.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drive.google.com | |
docs.google.com | |
meet.google.com | |
app.gotomeeting.com | |
hangouts.google.com |
I made sure to follow the instructions but no entry would show up in the default apps menu of Gnome. What worked for me was to execute
xdg-mime default choosy.desktop x-scheme-handler/http && xdg-mime default choosy.desktop x-scheme-handler/https
in the terminal to set it manually.
Glad you could make it work. Thanks for sharing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made sure to follow the instructions but no entry would show up in the default apps menu of Gnome. What worked for me was to execute
xdg-mime default choosy.desktop x-scheme-handler/http && xdg-mime default choosy.desktop x-scheme-handler/https
in the terminal to set it manually.