Skip to content

Instantly share code, notes, and snippets.

@ircykk
Created April 14, 2018 10:26
Show Gist options
  • Save ircykk/c35591ab0384f1d35a592ffa08029618 to your computer and use it in GitHub Desktop.
Save ircykk/c35591ab0384f1d35a592ffa08029618 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
@mirbehroznoor
Copy link

Thanks for the script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment