#!/bin/sh # List all paired devices and extract names and MAC addresses bluetoothctl devices | while read -r _ mac name; do printf '%s - %s\n' "$name" "$mac" done > /tmp/bt_devices.$$ # Use wofi to display the list of devices and capture the selected one selected_device=$(wofi --style ~/.config/wofi/style/style.css --show dmenu --prompt "Select Device" --width 300 --height 500 --lines 10 < /tmp/bt_devices.$$) # Clean up temp file rm -f /tmp/bt_devices.$$ # If a device is selected, connect to it if [ -n "$selected_device" ]; then mac_address=$(echo "$selected_device" | awk '{print $NF}') bluetoothctl connect "$mac_address" fi