Skip to content

Instantly share code, notes, and snippets.

@mildred
Last active February 10, 2022 14:48
Show Gist options
  • Save mildred/c44d6ca8ac76333ca4a2 to your computer and use it in GitHub Desktop.
Save mildred/c44d6ca8ac76333ca4a2 to your computer and use it in GitHub Desktop.
multifirefox

multifirefox: have multiple firefox profiles

Equivalent of firefox -P PROFILE_NAME -no-remote but with the remote enabled.

Multifirefox is a way to have multiple firefox profiles and open links in them. There are multiple ways of invocation:

multifirefox PROFILE_NAME ...

Start Firefox with the profile PROFILE_NAME (or open a new window in the existing firefox instance).

multifirefox [-] ...

Ask for the profile then start firefox (or open a window in the running Firefox profile).

Installation

  • put multifirefox on your PATH

  • put multifirefox.desktop in ~/.local/share/applications

  • run:

      xdg-mime default multifirefox.desktop x-scheme-handler/http x-scheme-handler/https
    
  • on GNOME, run:

      gvfs-mime --set x-scheme-handler/http multifirefox.desktop
      gvfs-mime --set x-scheme-handler/https multifirefox.desktop
    
#!/bin/bash
export LOGNAME="$USER"
profiles="$(cat ~/.mozilla/firefox/profiles.ini | grep Name= | cut -d= -f2)"
if echo "$profiles" | grep -Fx "$1" >/dev/null; then
profile="$1"
shift
export LOGNAME="$USER.$profile"
exec firefox -P "$profile" "$@"
else
if [[ -z "$1" ]] || [[ "a-" = "a$1" ]] || [[ "a--" = "a$1" ]]; then
shift
fi
if profile="$(echo "$profiles" | zenity --list --title="Choose a Firefox profile" --text="$*" --hide-header --column=)"; then
case "$profile" in
dev-edition-default)
exec firefox-developer "$@"
;;
default)
exec firefox "$@"
;;
*)
export LOGNAME="$USER.$profile"
exec firefox -P "$profile" "$@"
;;
esac
fi
fi
[Desktop Entry]
Name=Multi Firefox
Exec=/usr/bin/env multifirefox - %u
Icon=firefox
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true
Categories=Network;WebBrowser;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment