Skip to content

Instantly share code, notes, and snippets.

@cmj
Last active April 18, 2021 16:39
Show Gist options
  • Save cmj/e99e73b1a578c9fe86fdc27a88a34fe9 to your computer and use it in GitHub Desktop.
Save cmj/e99e73b1a578c9fe86fdc27a88a34fe9 to your computer and use it in GitHub Desktop.
Desktop notify for bluetooth headset battery levels.
#!/bin/bash
# libnotify script to display bluetooth battery level with corresponding Adwaita
# battery iconset
# https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level
# Battery level for 11:11:22:33:A3:1E is 40%
# example output: https://i.imgur.com/DH6Vd0V.png
src=$(bluetooth_battery.py $(bluetoothctl info | awk '/^Device/ {print $2}'))
dev=$(bluetoothctl info | sed -n '/Name/s/.*: //p')
num=$(echo ${src} | awk '{print substr($6, 1, length($6)-1)}')
icon="/usr/share/icons/Adwaita/96x96/status/battery-level-${num}-symbolic.symbolic.png"
notify-send -i "${icon}" "${dev} is ${num}%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment