X-Git-Url: https://mattmccutchen.net/utils/utils.git/blobdiff_plain/40ea9b7868f2b7746e7cbabfba6aba982096392a..273c390351c42303171c25215304d1cfd6ca02d4:/firefox-isolated diff --git a/firefox-isolated b/firefox-isolated new file mode 100755 index 0000000..50e143e --- /dev/null +++ b/firefox-isolated @@ -0,0 +1,60 @@ +#!/bin/bash +# Runs an isolated Firefox session in its own profile. - Matt 2007-12-02 + +#set -x + +MDD=~/.mozilla/firefox + +function write_profiles_ini { + ( + echo '[General]' + echo 'StartWithLastProfile=1' + echo + i=0 + for dir in *.*; do + if [ -d "$dir" ]; then + name="${dir#*.}" + echo "[Profile$i]" + echo "Name=$name" + echo "IsRelative=1" + echo "Path=$dir" + echo + let i=$i+1 + fi + done + ) >profiles.ini.tmp + mv profiles.ini.tmp profiles.ini +} + +function new_profile { + name="isolated-$$-$(date +%s)" + cp2 00000000.master/ "00000000.$name/" + write_profiles_ini + echo "$name" +} + +function liquidate_profile { + dir="00000000.$name" + cdir="changes_$name" + rsync -rl --compare-dest=../00000000.master --checksum "$dir/" "$cdir/" + rm -rf "$dir" + write_profiles_ini + find "$cdir" -type d -empty -delete + if [ -e "$cdir" ]; then + find_out="$(find "$cdir" -type f -print)" + zenity --info --text="This session changed the following files; you may wish to review the changes for application to the master profile: + +$find_out" + fi +} + +function run_isolated { + ff="$1" + shift + name="$(cd "$MDD"; new_profile)" + zenity --info --text="Beginning isolated Firefox session $name" + "$ff" -no-remote -P "$name" "$@" + (cd "$MDD"; liquidate_profile "$name") +} + +run_isolated /usr/bin/firefox "$@"