diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2024-03-07 18:19:59 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2024-03-07 18:19:59 -0500 |
| commit | b7d49e4dbc4672dd6c35bc487026f2fa0ebbc21b (patch) | |
| tree | edebe9d4ab27453b9ff2d71bb88eafae6c112129 /linux-bin/blu | |
| parent | c47200e3a2fd762efb23bfe974b440aa5cae8963 (diff) | |
| download | dotfiles-b7d49e4dbc4672dd6c35bc487026f2fa0ebbc21b.tar.gz dotfiles-b7d49e4dbc4672dd6c35bc487026f2fa0ebbc21b.tar.xz | |
Add a bluetooth wrapper script
Diffstat (limited to 'linux-bin/blu')
| -rw-r--r-- | linux-bin/blu | 47 |
1 files changed, 47 insertions, 0 deletions
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 + |
