#!/bin/sh
#
# ---
# see: https://soflow.nerdvpn.de/exchange/apple/questions/88096/placeholder

set -eu

readonly PLIST="global-currenthost-keyboard.plist"

# find globals
preference_file="$(find ~/Library/Preferences/ByHost -name '.GlobalPreference*')"

tmpfile="$(mktemp "${TMPDIR%/}"/"${PLIST}")" || tmpfile=/tmp/${PLIST}

# convert from binary format to XML
plutil -convert xml1 -o - "${preference_file}" >"${tmpfile}"

printf '%s\n' "Import into new system by running: defaults import -currentHost ${tmpfile}"
plutil -p "${tmpfile}"
