aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/sway/executable_bt-toggle.sh
blob: 02b72f9a8ddee7d4a04fd8f9b12a230ffa429fc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
# Toggle Bluetooth power via bluetoothctl. Uses notify-send's synchronous
# hint so repeated toggles replace the previous notification instead of
# stacking.
set -eu

state=$(bluetoothctl show | awk '/Powered:/ {print $2}')
if [ "$state" = "yes" ]; then
  bluetoothctl power off >/dev/null
  notify-send -t 1500 -h string:x-canonical-private-synchronous:bt \
    'Bluetooth' 'off'
else
  bluetoothctl power on >/dev/null
  notify-send -t 1500 -h string:x-canonical-private-synchronous:bt \
    'Bluetooth' 'on'
fi