Skip to content

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

Notifications You must be signed in to change notification settings

chbrown/plist-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

plist-utils

Install with GNU 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 <data> and <date> elements with <string> 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: Convert property list format to JSON.

  4. jq: Flatten the top-level array and select just a few fields from each network dictionary.

  5. mlr: 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.

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages