executable_firefox-temp-profile 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. set -o errexit -o pipefail
  3. OVERLAY=true
  4. profile="$(TMPDIR="${HOME}/.local/tmp" mktemp -d -t "firefox.XXXXXXXXXX")"
  5. FIREFOX_DEFAULT_PROFILE="j56dvo43.default-1520714705340"
  6. case "$1" in
  7. "default")
  8. profile_source_directory="${HOME}/.mozilla/firefox/${FIREFOX_DEFAULT_PROFILE}"
  9. if [[ $OVERLAY == true ]]
  10. then
  11. overlay_rw_directory="$(TMPDIR="${HOME}/.local/tmp" mktemp -d -t "overlay.XXXXXXXXXX")"
  12. upper_directory="${overlay_rw_directory}/upper"
  13. workdir_directory="${overlay_rw_directory}/work"
  14. trap "set +e; sudo umount '$profile'; rmdir '$profile'; sudo rm -rf '$overlay_rw_directory'" EXIT
  15. mkdir -p "$upper_directory"
  16. mkdir -p "$workdir_directory"
  17. sudo mount -t overlay overlay -o "lowerdir=${profile_source_directory},upperdir=${upper_directory},workdir=${workdir_directory}" "$profile"
  18. else
  19. trap 'rm -rf "$profile"' EXIT
  20. rsync --archive "${profile_source_directory}/" "${profile}/"
  21. fi
  22. ;;
  23. esac
  24. firefox --new-instance --profile "$profile" "$@"