diff --git a/config/.config/polybar/bars/bars.ini b/config/.config/polybar/bars/bars.ini index e0f53cc..f8e8cee 100644 --- a/config/.config/polybar/bars/bars.ini +++ b/config/.config/polybar/bars/bars.ini @@ -37,7 +37,7 @@ inherit = bar/base bottom = true modules-left = workspaces -modules-right = volume paddinglite battery +modules-right = bluetooth paddinglite volume paddinglite battery tray-position = center tray-maxsize = 28 diff --git a/config/.config/polybar/bars/colours.ini b/config/.config/polybar/bars/colours.ini index cd798fe..dd9adb1 100644 --- a/config/.config/polybar/bars/colours.ini +++ b/config/.config/polybar/bars/colours.ini @@ -28,6 +28,10 @@ orange- = #FEB548 orange = #F18F01 orange+ = #A26201 +rose- = #CC8FA0 +rose = #AB4E68 +rose+ = #7E3A4D + [colours/date] bg = ${colours.pear} fg = ${colours.gray} @@ -55,7 +59,11 @@ bg = ${colours.orange} fg = ${colours.gray} [colours/volume] -volume-bg = ${colours.blue} +volume-bg = ${colours.rose} volume-fg = ${colours.white} -muted-bg = ${colours.blue-} +muted-bg = ${colours.rose-} muted-fg = ${colours.white} + +[colours/bluetooth] +bg = ${colours.blue} +fg = ${colours.white} diff --git a/config/.config/polybar/bars/modules/bluetooth.ini b/config/.config/polybar/bars/modules/bluetooth.ini new file mode 100644 index 0000000..1d9e982 --- /dev/null +++ b/config/.config/polybar/bars/modules/bluetooth.ini @@ -0,0 +1,9 @@ +[module/bluetooth] +type = custom/script +exec = scripts/bluetooth.sh +interval = 5 +click-left = scripts/bluetooth.sh --toggle & + +format-background = ${colours/bluetooth.bg} +format-foreground = ${colours/bluetooth.fg} +format-padding = 1 diff --git a/config/.config/polybar/bars/scripts/bluetooth.sh b/config/.config/polybar/bars/scripts/bluetooth.sh new file mode 100755 index 0000000..34936b4 --- /dev/null +++ b/config/.config/polybar/bars/scripts/bluetooth.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +bluetooth_print() { + if bluetoothctl show | grep -q "Powered: yes"; then + printf '' + + devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2) + counter=0 + + for device in $devices_paired; do + device_info=$(bluetoothctl info "$device") + + if echo "$device_info" | grep -q "Connected: yes"; then + device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-) + + if [ $counter -gt 0 ]; then + printf ", %s" "$device_alias" + else + printf " %s" "$device_alias" + fi + + counter=$((counter + 1)) + fi + done + + printf '\n' + else + echo "" + fi +} + +bluetooth_toggle() { + if bluetoothctl show | grep -q "Powered: no"; then + bluetoothctl power on >> /dev/null + sleep 1 + + devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2) + echo "$devices_paired" | while read -r line; do + bluetoothctl connect "$line" >> /dev/null + done + else + devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2) + echo "$devices_paired" | while read -r line; do + bluetoothctl disconnect "$line" >> /dev/null + done + + bluetoothctl power off >> /dev/null + fi +} + +case "$1" in + --toggle) + bluetooth_toggle + ;; + *) + bluetooth_print + ;; +esac