diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-02-20 15:40:27 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-02-20 16:13:11 +0100 |
| commit | 198fa8e9cb94527733e09bc1b04c878320079520 (patch) | |
| tree | 7d089b166918a18f4e1a7d6af304689559ab6f14 /roles/hyprland/files/scripts/bluetooth.sh | |
| parent | 018fdcb5a16b7a984a38c78d8715f5e05bad3137 (diff) | |
Refactor waybar/hyprland
Diffstat (limited to 'roles/hyprland/files/scripts/bluetooth.sh')
| -rwxr-xr-x | roles/hyprland/files/scripts/bluetooth.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/roles/hyprland/files/scripts/bluetooth.sh b/roles/hyprland/files/scripts/bluetooth.sh new file mode 100755 index 00000000..7f276df4 --- /dev/null +++ b/roles/hyprland/files/scripts/bluetooth.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +turn_on() { + rfkill unblock bluetooth + bluetoothctl power on + notify "on" +} + +turn_off() { + rfkill unblock bluetooth + bluetoothctl power off + notify "off" +} + +toggle() { + if bluetoothctl <<< show | grep -q "Powered: yes"; then + turn_off + else + turn_on + fi +} + +notify() { + local class="$1" + notify-send -e \ + -h string:x-canonical-private-synchronous:bluetooth \ + -u low \ + "Bluetooth" \ + " ${class}" +} + +case "$1" in + "--on") + turn_on + ;; + "--off") + turn_off + ;; + "--toggle") + toggle + ;; + *) + echo -e "Usage:" + echo -e " --on to turn bluetooth on" + echo -e " --off to turn bluetooth off" + echo -e " --toggle to toggle bluetooth state" + exit 0 + ;; +esac |
