diff options
Diffstat (limited to 'polybar')
-rwxr-xr-x | polybar/.config/polybar/bt.sh | 64 | ||||
-rwxr-xr-x | polybar/.config/polybar/config | 11 |
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 | |||
3 | bluetooth_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 | |||
38 | bluetooth_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 | |||
57 | case "$1" in | ||
58 | --toggle) | ||
59 | bluetooth_toggle | ||
60 | ;; | ||
61 | *) | ||
62 | bluetooth_print | ||
63 | ;; | ||
64 | esac | ||
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 | |||
33 | module-margin-right = 1.5 | 33 | module-margin-right = 1.5 |
34 | font-0 = Input Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb | 34 | font-0 = Input Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb |
35 | font-1 = JetBrains Mono Nerd Font Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb | 35 | font-1 = JetBrains Mono Nerd Font Mono:style=medium:size=10:antialias=true:autohint=true:lcdfilter=lcddefault:rgba=rgb |
36 | modules-left = pulseaudio battery date time cmus | 36 | modules-left = pulseaudio battery date time bt cmus |
37 | modules-center = | 37 | modules-center = |
38 | modules-right = bspwm | 38 | modules-right = bspwm |
39 | tray-position = right | 39 | tray-position = right |
@@ -181,3 +181,12 @@ bar-progress-width = 10 | |||
181 | bar-progress-indicator = | | 181 | bar-progress-indicator = | |
182 | bar-progress-fill = ─ | 182 | bar-progress-fill = ─ |
183 | bar-progress-empty = ─ | 183 | bar-progress-empty = ─ |
184 | |||
185 | [module/bt] | ||
186 | type = custom/script | ||
187 | exec = ~/.config/polybar/bt.sh | ||
188 | tail = true | ||
189 | click-left = ~/.config/polybar/bt.sh --toggle & | ||
190 | format = tooth <label> | ||
191 | label = %output% | ||
192 | label-foreground = #EEFFFF | ||