Created
February 5, 2019 16:18
-
-
Save konchunas/265adbc4974c0559a374f0e7d3cbe17f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ADAPTER="Adapter1" | |
ADDRESS="hci0" | |
IS_BLUETOOTH_ON=$(dbus-send --system --dest=org.bluez --print-reply /org/bluez/${ADDRESS} org.freedesktop.DBus.Properties.Get string:org.bluez.${ADAPTER} string:Powered ) | |
DESIRED_STATE="false" | |
case $IS_BLUETOOTH_ON in | |
*false*) | |
DESIRED_STATE="true" | |
;; | |
esac | |
dbus-send --system --dest=org.bluez --print-reply /org/bluez/${ADDRESS} org.freedesktop.DBus.Properties.Set string:org.bluez.${ADAPTER} string:Powered variant:boolean:${DESIRED_STATE} | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
update:
here is a version which works on Linux Mint
I saved this to a file (in my case in
~/code/scripts/bluetooth-toggle.sh
) and made it executable withchmod +x ~/code/scripts/bluetooth-toggle.sh
. Then I assigned this to run via a keyboard shortcut using the GUI keyboard management tool