From 2ee4672b82bddf7e78aff7a2ef212f495debadac Mon Sep 17 00:00:00 2001 From: 0scar Date: Thu, 10 Jun 2021 10:15:24 +0200 Subject: Update statusbar scripts --- .local/bin/statusbar/bluetoothinfo | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 .local/bin/statusbar/bluetoothinfo (limited to '.local/bin/statusbar/bluetoothinfo') diff --git a/.local/bin/statusbar/bluetoothinfo b/.local/bin/statusbar/bluetoothinfo new file mode 100755 index 0000000..708f51e --- /dev/null +++ b/.local/bin/statusbar/bluetoothinfo @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +declare -a states + +ARG=${1:-$BLOCK_BUTTON} + +# Get state and exit if its soft/hard blocked +for A in $(rfkill -o TYPE,SOFT,HARD | awk '/bluetooth/{print $2 "\n" $3}'); do + [ $A == "blocked" ] && exit 0 +done + +DAEMONSTATUS="$(systemctl is-active bluetooth.service)" +if [ "$DAEMONSTATUS" == "inactive" ]; then + echo -en '\x0c\uf5b1\x0b' + case $ARG in + 1) systemctl start bluetooth.service;; + esac +else + CONNECTED="$(bluetoothctl info | awk '/Name/{$1=""; print $0}')" + if [ -z "${CONNECTED}" ]; then + # Not connected + echo -ne '\x0f\uf5b0\x0b' + case $ARG in + 1) notify-send 'Bluetooth status' "Disconnected\n$(bluetoothctl paired-devices)" + esac + else + echo -ne '\x0d\uf5ae\x0b' + case $ARG in + 1) notify-send 'Bluetooth status' "Connected to ${CONNECTED}";; + 3) bluetoothctl disconnect + esac + fi +fi -- cgit v1.3