Skip to main content

Module profile

Module profile 

Source
Expand description

Per-profile state isolation driven by the MIMICK_PROFILE env var.

When unset (the default), every state directory uses the literal mimick segment under the user’s XDG config / data / cache roots. When set to e.g. dev, the segment becomes mimick-dev, isolating config, the sharded SyncIndex, retries, and the thumbnail cache from the default profile.

Names are restricted to [A-Za-z][A-Za-z0-9_-]{0,31} so they remain valid both as filesystem path segments (no traversal) and as D-Bus / GTK application-id segments (must start with a letter). Invalid values are logged and ignored.

Constants§

MAX_PROFILE_LEN 🔒
Maximum character length of a valid profile name segment.
PROFILE_ENV_VAR 🔒
Environment variable key driving profile isolation.

Statics§

DIR_SEGMENT 🔒
Cached directory path segment mapped from environment.
PROFILE 🔒
Cached profile name parsed from environment.

Functions§

application_id
GTK / D-Bus application id. Varies by profile so multiple profiles can run as independent GTK instances. Always remains a valid D-Bus name because name() is sanitised to start with a letter.
cache_dir
Resolve user’s local cache directory parent based on profile.
config_dir
Resolve user’s local configuration directory parent based on profile.
data_dir
Resolve user’s local data directory parent based on profile.
dir_segment
Directory segment to use inside dirs::*_dir() paths.
keyring_account
Value for the keyring account attribute, scoping the API key per profile so switching profiles doesn’t overwrite the default’s secret. The default profile keeps the historical "api_key" value so existing installations continue to find their stored key.
name
Active profile name, or None when the default profile is in use.
profile 🔒
Helper to retrieve the current profile string, parsing and caching it once.
sanitise 🔒
Validate that a profile name is safe for filesystem and D-Bus usage.