Created
January 10, 2022 16:58
-
-
Save tyjak/abb0acf1bfd890713aadeef7e46fe834 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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