aboutsummaryrefslogtreecommitdiffstats
path: root/dwm-statusbar
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2026-03-21 17:50:16 +0100
committerEddy Pedroni <epedroni@pm.me>2026-03-21 17:50:16 +0100
commit8a613e438bce316adfa19fa392da95a9ccb21254 (patch)
treef2dbf9780dffacf66976a380ddd437230f0b2931 /dwm-statusbar
parentb35ccc26be06d6896e45be9b4cd0d19cda5e2f2b (diff)
Add bluetooth indicator to statusbarcustom
Diffstat (limited to 'dwm-statusbar')
-rwxr-xr-xdwm-statusbar25
1 files changed, 24 insertions, 1 deletions
diff --git a/dwm-statusbar b/dwm-statusbar
index 06803e3..90e3429 100755
--- a/dwm-statusbar
+++ b/dwm-statusbar
@@ -260,6 +260,29 @@ print_wlan() {
echo -ne "${icon_colour}\uE401${wlan_colour}${wlan_ip} ${wlan_strength}%"
}
+print_bluetooth() {
+ bt_status=$(systemctl is-active bluetooth)
+
+ if [[ "$bt_status" == "active" ]]; then
+ device_name=$(bluetoothctl info | grep Name: | sed -r 's/\s*Name: (.*?)/\1/g')
+ device_battery=$(bluetoothctl info | grep "Battery Percentage:" | sed -r 's/\s*Battery Percentage: .*?\(([0-9]+)\)/\1/g')
+ if [ $device_battery -lt 25 ]; then
+ icon_colour=${colour_critical}
+ battery_colour=${colour_critical}
+ elif [ $device_battery -lt 50 ]; then
+ icon_colour=${colour_warning}
+ battery_colour=${colour_warning}
+ else
+ icon_colour=${colour_neutral}
+ battery_colour=${colour_normal}
+ fi
+ echo -ne "${icon_colour}\uE212${battery_colour}${device_name} (${device_battery}%)"
+ else
+ icon_colour=${colour_faded}
+ echo -ne "${icon_colour}\uE212"
+ fi
+}
+
while true; do
# get new cpu idle and total usage
eval $(awk '/^cpu /{print "cpu_idle_now=" $5 "; cpu_total_now=" $2+$3+$4+$5 }' /proc/stat)
@@ -269,7 +292,7 @@ while true; do
# Pipe to status bar
# This is where you can adjust what gets shown by adding the desired function calls
- xsetroot -name "$(print_eth)${space}$(print_wlan)${space}$(print_root_free)${space}$(print_home_free)${space}$(print_cpu_used)${space}$(print_cpu_temp)${space}$(print_mem_free)${space}$(print_battery)${space}$(print_backlight)${space}$(print_volume)${space}$(print_time)$(print_date)"
+ xsetroot -name "$(print_eth)${space}$(print_wlan)${space}$(print_bluetooth)${space}$(print_root_free)${space}$(print_home_free)${space}$(print_cpu_used)${space}$(print_cpu_temp)${space}$(print_mem_free)${space}$(print_battery)${space}$(print_backlight)${space}$(print_volume)${space}$(print_time)$(print_date)"
# reset old rate
cpu_idle_old=$cpu_idle_now