Elektra: Plugin: mozprefs

Elektra 0.8.24

Plugin: mozprefs

- infos = Information about the mozprefs plugin is in keys below
- infos/author = Thomas Waser thoma.nosp@m.s.wa.nosp@m.ser@l.nosp@m.ibel.nosp@m.ektra.nosp@m..org
- infos/licence = BSD
- infos/needs =
- infos/provides = storage
- infos/recommends =
- infos/placements = getstorage setstorage
- infos/status = maintained reviewed conformant compatible coverage specific unittest tested nodep libc preview experimental difficult limited unfinished concept
- infos/metadata =
- infos/description = storage plugin for mozilla preferences

This plugin works on Mozilla preference files and is used in Elektra’s Firefox autoconfig script.

### Preference Types

- Default preferences: `pref(....`, keys below `mountpoint/pref/`.
- User preferences: `user_pref(....`, keys below `mountpoint/user/`.
- Lock preferences: `lockPref(....`, keys below `mountpoint/lock/`.
- Sticky preferences: `sticky_pref(....`, keys below `mountpoint/sticky/`.

Only Keys below one of these points are valid, everything else will be dropped

### Data Types

- `integer`
- `string`
- `boolean`

### Hierarchy

In Mozilla preference files `.` is used to separate sections, while elektra uses `/`. For simplification, and because `/` isn't allowed in preference keys, the plugin treats `.` and `/` equally.

    kdb set system/prefs/lock/a/lock/key lock
    kdb set system/prefs/lock/a/lock.key lock
    kdb set system/prefs/lock/a.lock.key lock

will all result in `lockPref("a.lock.key", "lock");`

## Example

```

# Backup-and-Restore:/tests/mozprefs

sudo kdb mount prefs.js /tests/mozprefs mozprefs

kdb setmeta user/tests/mozprefs/lock/a/lock/key type boolean kdb set /tests/mozprefs/lock/a/lock/key true kdb setmeta user/tests/mozprefs/pref/a/default/key type string kdb set /tests/mozprefs/pref/a/default/key "i'm a default key" kdb setmeta user/tests/mozprefs/user/a/user/key type integer kdb set /tests/mozprefs/user/a/user/key 123

kdb export user/tests/mozprefs ini #> [lock/a/lock] #> # type = boolean #> key = true #> [pref/a/default] #> # type = string #> key = i'm a default key #> [user/a/user] #> # type = integer #> key = 123

cat `kdb file user/tests/mozprefs` #> lockPref("a.lock.key", true); #> pref("a.default.key", "i'm a default key"); #> user_pref("a.user.key", 123);

# cleanup

kdb rm -r /tests/mozprefs sudo kdb umount /tests/mozprefs ```