#!/usr/bin/env bash
#
# The `bluetooth-forget` machine action: disconnect one device and remove it,
# so it stops coming back.
#
# The other half of pairing, and needed for the same reason: a controller that
# was trusted reconnects on its own for ever, and the only way to end that on a
# machine with no console is from the page.

set -euo pipefail

ARCHSTAR_ACTIONS_LIB="${ARCHSTAR_ACTIONS_LIB:-/usr/lib/archstar-actions/lib/common.sh}"
# shellcheck source=/dev/null
source "${ARCHSTAR_ACTIONS_LIB}"

main() {
    local address="${1:-}"
    require_address "${address}"
    bluetooth_verb forget "${address}"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
    main "$@"
fi
