Skip to content

Instantly share code, notes, and snippets.

View karlgrz's full-sized avatar

Karl Grzeszczak karlgrz

View GitHub Profile
@karlgrz
karlgrz / bluetooth_toggle.sh
Created May 5, 2017 14:58
After all these years, finally scripted up something to help with bluetooth connect / disconnect
#!/bin/bash
mac_addr="XX:XX:XX:XX:XX:XX" # your bluetooth headset MAC address goes here, pactl list to get it
sink_addr="${mac_addr//\:/_}"
bluez_card="bluez_card.${sink_addr}"
bluez_sink="bluez_sink.${sink_addr}"
if bluetoothctl <<< "info $mac_addr" | grep -qi "Connected: no"; then
echo "connecting ${bluez_card}..."
bluetoothctl <<< "connect $mac_addr"
sleep 5s