Initial commit
This commit is contained in:
39
dm-bluetooth/dm-bluetooth.sh
Executable file
39
dm-bluetooth/dm-bluetooth.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
option=$(echo -e "Restart Bluetooth\nManage Devices\nList connected devices" | dmenu -i -p "Do what?")
|
||||
if [ "$option" == "Restart Bluetooth" ]; then
|
||||
sudo systemctl restart bluetooth
|
||||
fi
|
||||
if [ "$option" == "Manage Devices" ]; then
|
||||
device=$(echo "devices" | bluetoothctl | tail -n +4 | head -n -1 | cut -c 26- | dmenu -i)
|
||||
if [ -n "$device" ]; then
|
||||
mac=$(echo "devices" | bluetoothctl | grep "$device" | grep -v 'devices' | head -n +1 | cut -c 8-24)
|
||||
option2=$(echo -e "Connect\nDisconnect\nReconnect\nRemove" | dmenu -i -p "$device ($mac)")
|
||||
if [ "$option2" == "Disconnect" ]; then
|
||||
echo "disconnect $mac" | bluetoothctl
|
||||
fi
|
||||
if [ "$option2" == "Reconnect" ]; then
|
||||
echo "disconnect $mac" | bluetoothctl
|
||||
sleep 2
|
||||
echo "connect $mac" | bluetoothctl
|
||||
fi
|
||||
if [ "$option2" == "Connect" ]; then
|
||||
echo "connect $mac" | bluetoothctl
|
||||
fi
|
||||
if [ "$option2" == "Remove" ]; then
|
||||
echo "remove $mac" | bluetoothctl
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "$option" == "List connected devices" ]; then
|
||||
IFS=$'\n'
|
||||
for device in $(echo devices | bluetoothctl | tail -n +4 | head -n -1 | cut -c 26-); do
|
||||
mac=$(echo "devices" | bluetoothctl | grep "$device" | grep -v 'devices' | head -n +1 | cut -c 8-24)
|
||||
connected=$(echo "info $mac" | bluetoothctl | grep "Connected: yes" )
|
||||
echo "$device $connected"
|
||||
if [ -n "$connected" ]; then
|
||||
notify-send -i apps/bluetooth "$device" "is connected"
|
||||
fi
|
||||
unset connected
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user