Named profiles for the home directory a box is given - #239
Open
kacperpaczos wants to merge 2 commits into
Open
Conversation
Creating a box already accepts a custom home directory, but it is a bare path field: nothing says what it changes, and anyone using it for more than one box has to remember the paths and retype them. A profile is that directory with a name on it. The primary menu gains a Profiles window listing them, each with the directory it points at, a Browse button that opens it in the file manager, and Remove. Adding one takes a name and puts the directory under ~/boxes; the directory itself is created when it is first needed rather than up front, since distrobox makes it when a box is built and Browse makes it when someone looks. The new-box form gets a Profile combo listing "Host (shared home)" first, then the profiles. Picking one fills in the home path; picking Host clears it, which is distrobox's own default and what every existing box uses. The folder picker still works for a one-off path, and the value handed to distrobox is unchanged - so this is a way of choosing the existing option, not a new mechanism. Profiles live in GSettings as a name-to-path map, the way exported-app labels do. Removing one forgets the setting only: the directory and any box already built on it are left alone.
The first version of this left the Home Directory entry and its folder button in place beside the new Profile combo, with the combo writing into the entry. Two controls for one setting, and nothing said which of them won - the field even kept its "Leave blank for default" label while the combo was the thing actually deciding. The row is now the only control. Its choices are Host (shared home), the profiles, and Custom folder…, which opens the same folder chooser as before; the chosen directory shows as the row's subtitle, so the path is still visible. Cancelling the chooser falls back to Host rather than leaving the row claiming a folder nobody picked. What is lost is typing a path by hand, which the entry allowed. In a graphical form a folder chooser is the better way to name a directory, and the alternative was keeping an ambiguity in the interface to preserve it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating a box already takes a custom home directory -
create_boxpasses it to--home- but it is a bare path field labelled "Home Directory (Leave blank for default)". Nothing says what it changes, and using it for more than one box means remembering paths and retyping them.This puts a name on that directory and calls it a profile.
What it does
~/boxes/<name>.Profiles are stored in GSettings as a name-to-path map (
a{ss}), the same shape and helper style as the terminal preference. No new dependencies, no new files.Why it is useful
A box whose home is its own keeps that home's dotfiles to itself, so an application running in it has its own settings and logins while the rest of the host's files stay reachable -
/home/you/projectsis still there, just not under~. Exports are unaffected:distrobox-exportresolves the host home fromDISTROBOX_HOST_HOME, so applications added to the menu and commands added to the terminal still land on the host. That makes a box a usable profile for a tool you sign into, without a second user account.The directory is created when it is first needed - by distrobox when a box is built, or by Browse when someone looks at it - rather than at the moment the profile is named.
Screenshots
Testing
cargo test: 7 pass, including new ones pinning the name rules (acceptswork,Personal 2,a_b-c; rejects empty, whitespace, over-long, and anything with/,"or$).End to end on a virtual display with an isolated
$HOME, an isolated GSettings keyfile backend and a scratch schema: adding a profile writesprofiles={'praca': '…/boxes/praca'}and the row appears with both buttons; Browse creates the directory that was not there before. With a stubdistroboxlogging its arguments, creating a box gives:so nothing changes unless a profile is chosen.
Two things worth a decision
Not included here, deliberately: changing an existing box's profile. A container's home is fixed when it is created, so that would mean recreating it. The safe shape is to offer the profile choice in the existing Clone Box flow, so the original is untouched until the copy is known to work - a follow-up if you like the direction.