random/bluetooth-toggle

13 lines
359 B
Bash

#!/bin/sh
# Toggles bluetooth on a Linux system. Make sure that you have bluetoothctl installed.
# I use it with a shortcut.
if [ $(bluetoothctl show | grep Powered | grep -c yes) -eq 1 ]; then
bluetoothctl power off
else
if [ $(rfkill --output-all | grep bluetooth | grep -c blocked) -ne 0 ]; then
rfkill unblock bluetooth
fi
bluetoothctl power on
fi