aboutsummaryrefslogtreecommitdiff
path: root/extras/HOME/.local/bin/bluetooth-select.sh
blob: 3a253878f190b5ab749abc3f427dcbd312e042f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

if [[ -z "$ROFI" ]] ; then
  ROFI='rofi -dmenu'
fi

devices="$(bluetoothctl -- devices | sed 's#^Device ##')"
selection="$(
  echo -e "$devices\nDisconnect" | $ROFI -i -p "Connect Bluetooth" \
    -theme-str '* {theme-color: #8888ff;}' \
    -dmenu)"

macaddr="${selection%% *}"

if [[ "$macaddr" == "Disconnect" ]] ; then
  exec bluetoothctl -- disconnect
fi

exec bluetoothctl -- connect "$macaddr"