#!/bin/sh
set -euC

action="${1:-"info"}"
devices="68:D6:ED:1F:49:EF 41:42:96:48:5F:1F"

info()
{
  for device in $devices
  do
    bluetoothctl info "$device" | awk '/^\s*(Device|Name|Paired|Connected)/'
  done
}

pair()
{
  bluetoothctl scan on
  bluetoothctl pair "$1" || true
  bluetoothctl scan off
}

on()
{
  bluetoothctl power on
  for device in $devices
  do
    bluetoothctl connect "$device" &
  done
}

off()
{
  for device in $devices
  do
    bluetoothctl disconnect "$device" &
  done
  bluetoothctl power off
}

"$action"
wait