first commit

main
Graham Helton 2 years ago
commit 02fc802399

@ -0,0 +1,32 @@
# Bluetoother
## Usage
1. Install the bluetooth software
```bash
sudo apt-get -y install bluetooth bluez bluez-tools rfkill
```
2. Find out your device's hardware MAC Address
```bash
bluetoothctl
scan on
<turn your device on and look for it in the scan list>
scan off
exit
```
2. Edit the script and input your hardware's MAC address
3. Run the script
```bash
git clone https://github.com/grahamhelton/bluetoother
chmod +x bluetoother
./bluetoother
-> Bluetooth service enabled, trying to connect you...
-> You're connected!
```
## Running with keypress in I3
bindsym #Mod+shift+b exec /path/to/bluetoother
## References
https://computingforgeeks.com/connect-to-bluetooth-device-from-linux-terminal/

@ -0,0 +1,28 @@
#! /bin/bash
mac="INSERT YOUR MAC ADDRESS HERE"
active=$(systemctl is-active bluetooth.service)
if [[ "$active" == "active" ]]; then
echo "Bluetooth service enabled, trying to connect you..."
else
echo "Bluetooth is not enabled. Running systemctl start bluetooth.service"
systemctl start bluetooth.service
fi
#unblock bluetooth
rfkill unblock bluetooth
# Use bluetoothctl utility to make the connection.
bluetoothctl remove $mac 1>/dev/null
bluetoothctl agent KeyboardOnly 1>/dev/null
bluetoothctl default-agent 1>/dev/null
bluetoothctl power on 1>/dev/null
# if your mac address is found, connect to it
if bluetoothctl scan on | grep -q "$mac"; then
bluetoothctl pair $mac 1>/dev/null
bluetoothctl trust $mac 1>/dev/null
if bluetoothctl connect $mac | grep -q "Connection successful"; then
echo "You're connected!"
exit 0
fi
fi
echo "Could not connect"
Loading…
Cancel
Save