Skip to content

Instantly share code, notes, and snippets.

@tyjak
Created January 10, 2022 16:58
Show Gist options
  • Save tyjak/abb0acf1bfd890713aadeef7e46fe834 to your computer and use it in GitHub Desktop.
Save tyjak/abb0acf1bfd890713aadeef7e46fe834 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# utility to get level battery for i3pystatus
# need the device name as argument
# GistID: abb0acf1bfd890713aadeef7e46fe834
MAC=$(bluetoothctl devices | grep "$1" | cut -d" " -f2)
LEVEL=$(bluetoothctl info $MAC | grep -q Connected && based-connect $MAC -b)
if [ $LEVEL ]
then
echo " ${LEVEL}%"
if [ $LEVEL -lt 11 ]
then
exit 1
fi
else
echo ""
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment