Set up Bluetooth toggling via keyboard shortcut

Based on this Gist

It didn’t work on Linux Mint, but this variant did

#!/bin/sh

IS_BLUETOOTH_ON=$(dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0 org.freedesktop.DBus.Properties.Get string:org.bluez.Adapter1 string:Powered )

case $IS_BLUETOOTH_ON in 
  *false*)
    rfkill unblock 0
    ;;
  *true*)
    rfkill block 0
    ;;
esac

exit 0

I saved this to a file (in my case in ~/code/scripts/bluetooth-toggle.sh ) and made it executable with chmod +x ~/code/scripts/bluetooth-toggle.sh . Then I assigned this to run via a keyboard shortcut using the GUI keyboard management tool