Add browsers to profile-sync-daemon on my own
- Date Created
- Date Modified
Profile-sync-daemon
Profile-sync-daemon is a script that relocates browser profiles from the drive to the RAM disk. A browser profile is the files that is read/written at runtime, such as browser settings (including bookmarks and extensions), cookies, etc. It is often about 100 MB or more for an ordinary browser.
By using profile-sync-daemon(psd), you will get faster operation and less I/O to the SSD (that makes SSD live longer!).
As you can see from the high praise on the Arch wiki, it was created by one of the Arch Linux developer, so if you are using an Arch distribution, there is no reason not to use it. Of course, official packages are available for many major distributions such as Debian, Ubuntu, Fedora, and Gentoo, in addition to Arch.
How to use
Arch can install it from official extra repo by pacman.
$ sudo pacman -S profile-sync-daemonEdit the config file.
$ nano ~/.config/psd/psd.confAdd the browsers in the parentheses of BROWSERS,
separating by spaces. Supported browsers are limited to those
listed under Possible values:.
BROWSERS=(firefox icecat chromium)
It is controlled by systemd. Make sure do it with
--user.
$ systemd --user start psd.service
$ systemd --user enable psd.serviceYou can check how much memory is actually being used by
psd preview.
Add browsers on your own
Here’s the main point. Add browsers that is not supported by psd. Please be aware that future updates may destroy your environment, so please do so at your own risk.
Browsers to add this time
- Firefox-ESR
- LibreWolf
Firefox-ESR
is a long-term support version of Firefox, and although Mozilla
emphasizes that it is for “enterprise” it is highly stable and I
recommend to use ESR if you are not particular about it.
Internally, it runs as a separate software from the regular
version of Firefox, so it can be used together with the regular
version.
The specification has been changed since version 140.0 to use the same profile directory as the regular Firefox.
LibreWolf is a browser that eliminates Mozilla-specific sponsored links and telemetry from Firefox and applies the strictest privacy settings. Recommended for those who value privacy but feel IceCat bit too much.
Psd specification
Looking at the source
code, it seems that a shell script for each browser is
placed in /usr/share/psd/browsers and that it is
executed after checking for the existence of a file with the
same name as the argument of BROWSERS.
/usr/share/psd/browsers
This could be applied by simply putting my own shell scripts
in /usr/share/psd/browsers. I really appreciate
this kind of design, because I don’t have to build, package, and
install it myself.
Check the shell scripts
if [[ -d "$HOME"/.mozilla/firefox ]]; then
index=0
PSNAME="$browser"
while read -r profileItem; do
if [[ $(echo "$profileItem" | cut -c1) = "/" ]]; then
# path is not relative
DIRArr[$index]="$profileItem"
else
# we need to append the default path to give a
# fully qualified path
DIRArr[$index]="$HOME/.mozilla/firefox/$profileItem"
fi
(( index=index+1 ))
done < <(grep '[Pp]'ath= "$HOME"/.mozilla/firefox/profiles.ini | sed 's/[Pp]ath=//')
fi
check_suffix=1
It seems to extract full path of the profiles.
Check Firefox specification
Note that the profile specifications have changed since Firefox-ESR 140.0
Since all the browsers to be added this time are Firefox-based, check the Firefox profile specifications.
about:profiles
Information on where the profiles are located and which one
is currently applied can be found at
about:profiles.
Information for managing profiles is compiled in the file
profile.ini in the directory where the profiles are
located.
[Profile1]
Name=default
IsRelative=1
Path=lekocygz.default
Default=1
[Profile0]
Name=default-release
IsRelative=1
Path=wymt0yba.default-release
[General]
StartWithLastProfile=1
Version=2
[Install3B6073811A6ABF12]
Default=wymt0yba.default-release
Locked=1
The profile usually used is default-release,
where default is the profile in the old
specification, and is meant to be a backup in case of
emergency.
Firefox seems to distinguish multiple profiles by their
suffix like default-release-1, which requires
check_suffix=1 in the shell script.
Deploy shell scripts.
Since Firefox-ESR 140.0, this is no longer necessary
if [[ -d "$HOME"/.mozilla/firefox-esr ]]; then
index=0
PSNAME="$browser"
while read -r profileItem; do
if [[ $(echo "$profileItem" | cut -c1) = "/" ]]; then
# path is not relative
DIRArr[$index]="$profileItem"
else
# we need to append the default path to give a
# fully qualified path
DIRArr[$index]="$HOME/.mozilla/firefox-esr/$profileItem"
fi
(( index=index+1 ))
done < <(grep '[Pp]'ath= "$HOME"/.mozilla/firefox-esr/profiles.ini | sed 's/[Pp]ath=//')
fi
check_suffix=1
LibreWolf had a profile directory ~/.librewolf,
not ~/.mozilla, so fix that.
if [[ -d "$HOME"/.librewolf ]]; then
index=0
PSNAME="$browser"
while read -r profileItem; do
if [[ $(echo "$profileItem" | cut -c1) = "/" ]]; then
# path is not relative
DIRArr[$index]="$profileItem"
else
# we need to append the default path to give a
# fully qualified path
DIRArr[$index]="$HOME/.librewolf/$profileItem"
fi
(( index=index+1 ))
done < <(grep '[Pp]'ath= "$HOME"/.librewolf/profiles.ini | sed 's/[Pp]ath=//')
fi
check_suffix=1
You can leave owner as root and the permission
as 644.
Add browsers to psd.conf …
BROWSERS=(librewolf firefox icecat chromium)
If there is no error after restarting psd from systemd, you have succeeded.
$ systemctl --user stop psd
$ systemctl --user start psdCheck how it works by psd preview.
Conclusion
If you do it, you really do it at your own risk please.
Changelog
: Removed incorrect information that “psd also synchronizes the cache” While the cache is also stored on tmpfs, it is located in a different place from the profile directory, and psd is not involved.
: Fixed typo and some
misunderstaindings about cache. The incorrect explanation
stating “browser profile is the files … cache, cookies,
etc.” has been corrected. Cookies are included in the
profile directory, but cache is stored in a separate cache
directory ($HOME/.cache/mozilla/firefox in Firefox)
distinct from the profile.
: Just after I wrote this article,
the Firefox-ESR
140.0 was released, and the profile directory was changed
from ~/.mozilla/firefox-esr to
~/.mozilla/firefox. That means, psd can handle ESR
just by entering BROWSERS=(firefox) in the config.
Please be sure to check the directory where the profile is
located before working on it. And please keep conscious on
current specification and read release notes carefully to
prepare changes in the future.
License Information
Add browsers to profile-sync-daemon on my own is licensed under a Creative Commons [Attribution 4.0 International] License.