diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2021-06-10 08:15:24 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2021-06-10 08:15:24 +0000 |
| commit | 2ee4672b82bddf7e78aff7a2ef212f495debadac (patch) | |
| tree | 9ce6557e5cd666dddbb4e26c377c75451cc0df6f /.local/bin/statusbar/bluetoothinfo | |
| parent | cd9049c5033f2c403bfdae1e997790d67523d1ba (diff) | |
Update statusbar scripts
Diffstat (limited to '.local/bin/statusbar/bluetoothinfo')
| -rwxr-xr-x | .local/bin/statusbar/bluetoothinfo | 33 |
1 files changed, 33 insertions, 0 deletions
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 |
