Skip to content

Instantly share code, notes, and snippets.

@polaroidkidd
Created November 3, 2020 22:10
Show Gist options
  • Select an option

  • Save polaroidkidd/39bdd0c2041b0b9cc69d0be7d88590f2 to your computer and use it in GitHub Desktop.

Select an option

Save polaroidkidd/39bdd0c2041b0b9cc69d0be7d88590f2 to your computer and use it in GitHub Desktop.

Revisions

  1. polaroidkidd created this gist Nov 3, 2020.
    10 changes: 10 additions & 0 deletions toggle-bluetooth.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/usr/bin/env bash
    set -e

    BLUETOOTH_STATE=$(dbus-send --session --dest=org.blueman.Applet --print-reply=literal /org/blueman/applet org.blueman.Applet.GetBluetoothStatus | sed "s/^[[:space:]].*boolean //g")

    if [ "${BLUETOOTH_STATE}" == "true" ]; then
    dbus-send --session --dest=org.blueman.Applet --print-reply /org/blueman/applet org.blueman.Applet.SetBluetoothStatus boolean:false
    else
    dbus-send --session --dest=org.blueman.Applet --print-reply /org/blueman/applet org.blueman.Applet.SetBluetoothStatus boolean:true
    fi