Expand the JSON strings stored in the Morpheusly UI config file
Overview
This is a small, simple tool that makes it a bit easier to compare and
generally examine the shared_settings.json file stored by
the Morpheusly UI.
Install into a virtual environment
uv venv /path/to/venv
(set -e; . /path/to/venv/bin/activate; uv pip install /path/to/mrph-expand-config-source)
Or using the traditional Python venv and pip tools:
python3 -m venv --upgrade-deps /path/to/venv
/path/to/venv/bin/python3 -m pip install /path/to/mrph-expand-config-source
Examples
Expand the fields, then use jq to grab the node ID:
mrph-expand-config -q expand ~/.local/share/morpheuslyapp/shared_preferences.json \
| jq '."flutter.command-node-config".settings.node_id'
Using the -s (--sort-keys) option to make it possible to use diff,
compare two files using the <(command) shell syntax:
diff -u \
<(mrph-expand-config expand -s ~/.local/share/morpheuslyapp/0-shared_preferences-after-recreate.json) \
<(mrph-expand-config expand -s ~/.local/share/morpheuslyapp/shared_preferences.json)
Using a single dash (-) as the input filename, read a piped JSON object from the process's
standard input stream and obtain the API session cookie:
cookie="$(docker exec -- docker_server_1 \
cat /home/morpheusly/.local/share/com.morpheusly.morpheuslyapp/shared_preferences.json \
| mrph-expand-config expand - \
| jq -r '."flutter.command-node-config".cookie')"
Do the same, but use the jq subcommand of mrph-expand-config, passing
the expression using the --expr / -e option and additional arguments using
the --arg / -a option:
cookie="$(docker exec -- docker_server_1 \
cat /home/morpheusly/.local/share/com.morpheusly.morpheuslyapp/shared_preferences.json \
| mrph-expand-config jq -a -r -e '."flutter.command-node-config".cookie' -)"
If more than one argument needs to be passed to jq, the --args option may
be used; it accepts a single argument that will be split into words according to
the POSIX shell splitting rules:
The --in-place option of the jq subcommand will cause mrph-expand-config to
read the configuration settings, expand them, pass them through the specified jq
transformation, then collapse the JSON output and write it back to the same
configuration file it was read from:
mrph-expand-config \
jq \
--in-place \
--args '--arg server proxy.example.com' \
-e '."flutter.command-node-config".settings.proxyserver_hostname = $server'
Contact
The mrph-expand-config library was written by Peter Pentchev.
It is developed in a GitLab repository. This documentation is
hosted at Ringlet with a copy at [ReadTheDocs][readthedocs].