Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chbrown/plist-utils

Tools for manipulating files/streams in Apple's "property list" format
https://github.com/chbrown/plist-utils

apple macos plist xml

Last synced: 10 days ago
JSON representation

Tools for manipulating files/streams in Apple's "property list" format

Awesome Lists containing this project

README

        

# plist-utils

Install with [GNU Stow](https://www.gnu.org/software/stow/):

git clone https://github.com/chbrown/plist-utils
cd plist-utils
stow -t /usr/local/bin bin

### `plprint`

Convert a file in Apple's "property list format" into XML (whether binary or already XML),
then pretty print with `xmllint`.
The plist file can be supplied as a single argument, or on `/dev/stdin`.

plprint Config.plist

### `pljson`

Simplify the XML of the given plist file with XMLStarlet,
replacing `` and `` elements with `` elements,
and convert to JSON.

pljson Config.plist

### `plxml`

Convert each of the specified Apple Property List files to `XML` in-place,
preserving file timestamps and permissions.

plxml settings.bin.plist

## Recipes

The macOS `airport` utility has a scan option, `-s`,
but by default, the output is unstructured and difficult to manipulate.
The `-x` option produces XML that contains a _lot_ more information in structured (if verbose) `plist` format.

Using `pljson` and a few other commands,
we can sort the available networks with strongest (largest RSSI) connections first:

airport -s -x \
| iconv -f macroman -t UTF-8 \
| pljson \
| jq -c '.[] | {SSID_STR,BSSID,RSSI,CHANNEL,CHANNEL_FLAGS,CAPABILITIES}' \
| mlr --ijson --opprint sort -nr RSSI

Pipeline components:

1. `airport -s -x`:
Run a network scan and produce XML output.
2. `iconv`:
Convert encoding from Mac-Roman to UTF-8.
Sometimes networks advertise names that are not UTF-8, which `airport` doesn't convert,
despite clearly denoting the encoding as `UTF-8` in the XML declaration.
3. [`pljson`](#pljson):
Convert property list format to JSON.
4. [`jq`](https://stedolan.github.io/jq/):
Flatten the top-level array and select just a few fields from each network dictionary.
5. [`mlr`](https://johnkerl.org/miller/doc/):
Read in JSON and output whitespace-aligned tabular output, sorted by descending RSSI.
RSSI ranges from -100 (weakest) to 0 (strongest).

| RSSI | Description |
|-----:|:------------------|
| 0 | impossibly strong |
| -30 | amazing |
| -70 | average |
| -90 | unusable |

## License

Copyright 2017-2018 Christopher Brown.
[MIT Licensed](https://chbrown.github.io/licenses/MIT/#2017-2018).