Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mirbehroznoor/d974946eb56f3426250903e8d94aef1d to your computer and use it in GitHub Desktop.
Save mirbehroznoor/d974946eb56f3426250903e8d94aef1d to your computer and use it in GitHub Desktop.
Linux bluetoothctl auto pair and connect device
#!/bin/bash
coproc bluetoothctl
echo -e 'scan on\n' >&${COPROC[1]}
sleep 3
echo -e 'remove AA:AA:AA:AA:AA:AA\n' >&${COPROC[1]}
sleep 1
echo -e 'pair AA:AA:AA:AA:AA:AA\n' >&${COPROC[1]}
sleep 1
echo -e 'connect AA:AA:AA:AA:AA:AA\n' >&${COPROC[1]}
sleep 1
echo -e 'scan off\n' >&${COPROC[1]}
echo -e 'exit\n' >&${COPROC[1]}
output=$(cat <&${COPROC[0]})
echo $output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment