From b7d49e4dbc4672dd6c35bc487026f2fa0ebbc21b Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Thu, 7 Mar 2024 18:19:59 -0500 Subject: Add a bluetooth wrapper script --- linux-bin/Makefile | 5 ++++- linux-bin/blu | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 linux-bin/blu (limited to 'linux-bin') diff --git a/linux-bin/Makefile b/linux-bin/Makefile index eb1db92..af087c0 100644 --- a/linux-bin/Makefile +++ b/linux-bin/Makefile @@ -10,7 +10,10 @@ install-backlight: backlight install -D -o root -g $(WHEEL) -m 755 backlight /sbin/ chmod 6750 /sbin/backlight -install: install-zzz install-backlight +install-blu: + install -D -o root -g $(WHEEL) -m 755 blu /bin/ + +install: install-zzz install-backlight install-blu clean: rm -f zzz backlight diff --git a/linux-bin/blu b/linux-bin/blu new file mode 100644 index 0000000..c02eb30 --- /dev/null +++ b/linux-bin/blu @@ -0,0 +1,47 @@ +#!/bin/sh +# Small bluetooth wrapper to make common tasks more friendly. +set -e + +getDevice() { + bluetoothctl devices Paired | grep "$1" | sed 1q | awk '{print $2}' +} + +if [ $# -eq 0 ] ; then + bluetoothctl devices Paired + exit 0; +fi + +case $1 in +on|up) + bluetoothctl power on +;; +off|down) + bluetoothctl power off +;; +c*) + shift; + device="$(getDevice "$1")"; shift; + bluetoothctl connect "$device" "$@" +;; +d*) + shift; + device="$(getDevice "$1")"; shift; + bluetoothctl disconnect "$device" "$@" +;; +t*) + shift; + device="$(getDevice "$1")"; shift; + bluetoothctl trust "$device" "$@" +;; +b*) + shift; + device="$(getDevice "$1")"; shift; + bluetoothctl block "$device" "$@" +;; +ub*|unblock) + shift; + device="$(getDevice "$1")"; shift; + bluetoothctl unblock "$device" "$@" +;; +esac + -- cgit v1.2.3