Last active
May 25, 2020 06:31
-
-
Save petr001/678efd4c7398f8d34f57393fdcb94bc5 to your computer and use it in GitHub Desktop.
Bitbar (https://getbitbar.com) plugin. Copy to plugin folder and add X permission (`chmod u+x apple-mouse-keyboard-battery.1m.sh`)
This file contains 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/sh | |
# <bitbar.title>Apple Mouse and Keyboard Battery Percentage</bitbar.title> | |
# <bitbar.version>1.0</bitbar.version> | |
INFO=$( | |
ioreg -r -l -n AppleHSBluetoothDevice | | |
egrep '"BatteryPercent" = |^ \| "Bluetooth Product Name" = ' | | |
sed 's/ | "Bluetooth Product Name" = "Magic Mouse 2"/🖱 /' | | |
sed 's/ | "Bluetooth Product Name" = "Magic Keyboard"/\⌨️ /'| | |
sed 's/ | "BatteryPercent" = //' | | |
sed -E 's/([0-9]+)/\1% /' | |
); | |
if [ "$INFO" ]; then | |
echo $INFO " | size=12" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment