So in my previous attempt at making user personas “easy” I ran into a roadblock. Systemd saw that I was bind-mounting a directory in my microSD card over my /home/purism directory and was automatically creating a dependency chain. This meant that if the microSD card were missing, systemd would disable phosh and other dependencies and you’d be left with a blinking text login prompt.
In the interest of making this even easier, I decided to take the approach of hosting each persona in /home directly and make /home/purism a symlink you would change to point to the different personas. Then you could create personas, back them up, and delete them from /home when you don’t want to take them with you.
I wrapped this in a basic yad script and have tested it reasonably well. You can check it out here:
WARNING!! I have tested this script pretty well but because we are dealing with moving home directories around, and because this has a “delete persona” feature, it could remove your personal files (by design!). Be sure to backup your entire /home directory if you choose to try this out.
That repo has a corresponding .desktop file as well. I recommend putting the script in /usr/local/bin and the .desktop file in /usr/local/share/applications. If you store the script in your home directory instead, it will disappear when you switch personas!
Internally we’ve already found a few handy use cases for this, in particular creating a new blank persona that we can use when filming Librem 5 videos, that doesn’t have any of our actual personal contacts or other settings.
Because all of the personas are owned by the same user, if you were to create, say, a “guest” persona and switch to it, a clever guest would be able to browse the file system and still see your other personas in /home.
A better long-term approach would be to use real, separate users and rely on file system permissions to protect one persona from another. Because phosh on the Librem 5 is tied into UID 1000, changing it would mean modifying phosh’s systemd unit file each time you switch personas, along with adding the plumbing to manage new user accounts. I just haven’t gone to the trouble yet.
Bonus MicroSD progress
Something I noticed after implementing this mode, is that having /home/purism be a symlink is enough to trick systemd so that I was able to move my home directory back to a microSD card and use a bind mount to its corresponding persona directory in /home. When the microSD card is absent, the bind mount fails, but since /home/purism is still symlinked to the (empty) /home/default directory I created for that persona, it fails safely into a fresh desktop.
To move a persona to microSD (which I will probably offer as a feature in a future version of the script), you can follow my steps from my previous persona attempt with bind mounts, only you set up the bind mount from the home directory on your microSD card, to the persona in /home and not the /home/purism symlink.