summaryrefslogtreecommitdiff
path: root/polybar
diff options
context:
space:
mode:
Diffstat (limited to 'polybar')
-rwxr-xr-xpolybar/.config/polybar/bt.sh64
-rwxr-xr-xpolybar/.config/polybar/config11
2 files changed, 74 insertions, 1 deletions
diff --git a/polybar/.config/polybar/bt.sh b/polybar/.config/polybar/bt.sh
new file mode 100755
index 0000000..f754059
--- /dev/null
+++ b/polybar/.config/polybar/bt.sh
@@ -0,0 +1,64 @@
1#!/bin/sh
2
3bluetooth_print() {
4 bluetoothctl | while read -r; do
5 if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then
6 # printf 'on'
7
8 devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
9 counter=0
10
11 for device in $devices_paired; do
12 device_info=$(bluetoothctl info "$device")
13
14 if echo "$device_info" | grep -q "Connected: yes"; then
15 device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
16
17 if [ $counter -gt 0 ]; then
18 printf ", %s" "$device_alias"
19 else
20 printf " %s" "$device_alias"
21 fi
22
23 counter=$((counter + 1))
24 elif bluetoothctl show | grep -q "Powered: yes"; then
25 printf "disconnected"
26 else
27 printf "off"
28 fi
29 done
30
31 printf '\n'
32 else
33 echo "off"
34 fi
35 done
36}
37
38bluetooth_toggle() {
39 if bluetoothctl show | grep -q "Powered: no"; then
40 bluetoothctl power on >> /dev/null
41 sleep 1
42
43 devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
44 echo "$devices_paired" | while read -r line; do
45 bluetoothctl connect "$line" >> /dev/null
46 done
47 else
48 devices_paired=$(bluetoothctl paired-devices | grep Device | cut -d ' ' -f 2)
49 echo "$devices_paired" | while read -r line; do
50 bluetoothctl disconnect "$line" >> /dev/null
51 done
52
53 bluetoothctl power off >> /dev/null
54 fi
55}
56
57case "$1" in
58 --toggle)
59 bluetooth_toggle
60 ;;
61 *)
62 bluetooth_print
63 ;;
64esac
diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config
index b5c486a..477fa30 100755
--- a/polybar/.config/polybar/config
+++ b/polybar/.config/polybar/config
@@ -33,7 +33,7 @@ module-margin-left = 1.5
33module-margin-right = 1.5 33module-margin-right = 1.5
34font-0 = Input Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb 34font-0 = Input Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb
35font-1 = JetBrains Mono Nerd Font Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb 35font-1 = JetBrains Mono Nerd Font Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb
36modules-left = pulseaudio battery date time cmus 36modules-left = pulseaudio battery date time bt cmus
37modules-center = 37modules-center =
38modules-right = bspwm 38modules-right = bspwm
39tray-position = right 39tray-position = right
@@ -181,3 +181,12 @@ bar-progress-width = 10
181bar-progress-indicator = | 181bar-progress-indicator = |
182bar-progress-fill = ─ 182bar-progress-fill = ─
183bar-progress-empty = ─ 183bar-progress-empty = ─
184
185[module/bt]
186type = custom/script
187exec = ~/.config/polybar/bt.sh
188tail = true
189click-left = ~/.config/polybar/bt.sh --toggle &
190format = tooth <label>
191label = %output%
192label-foreground = #EEFFFF