Added bluetooth module in polybar
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
9
config/.config/polybar/bars/modules/bluetooth.ini
Normal file
9
config/.config/polybar/bars/modules/bluetooth.ini
Normal file
@@ -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
|
||||
58
config/.config/polybar/bars/scripts/bluetooth.sh
Executable file
58
config/.config/polybar/bars/scripts/bluetooth.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user