From 749fd7b3ac961f087533cbfe610c2522900f298a Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Fri, 31 Dec 2021 16:04:23 +0100 Subject: [PATCH] Add dmenu bluetooth menu --- .bin/dmenu-bluetooth | 10 ++++++++++ .bin/toggle-bt-device | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100755 .bin/dmenu-bluetooth create mode 100755 .bin/toggle-bt-device diff --git a/.bin/dmenu-bluetooth b/.bin/dmenu-bluetooth new file mode 100755 index 0000000..c7f2855 --- /dev/null +++ b/.bin/dmenu-bluetooth @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +options="Mouse\nHeadphones" + +selected="$(echo -e "$options" | dmenu -i)" + +case "$selected" in + "Mouse") toggle-bt-device E4:19:21:56:C8:70;; + "Headphones") toggle-bt-device 38:18:4C:D4:74:42;; +esac diff --git a/.bin/toggle-bt-device b/.bin/toggle-bt-device new file mode 100755 index 0000000..2792b9f --- /dev/null +++ b/.bin/toggle-bt-device @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +status="$(bluetoothctl info "$1" | grep Connected | cut -f 2 -d ':' | cut -f 2 -d ' ')" + +if [ "$status" == "no" ] +then + bluetoothctl connect "$1" +elif [ "$status" == "yes" ] +then + bluetoothctl disconnect "$1" +fi