Skip to content

Instantly share code, notes, and snippets.

@petr001
petr001 / apple-mouse-keyboard-battery.1m.sh
Last active May 25, 2020 06:31
Bitbar (https://getbitbar.com) plugin. Copy to plugin folder and add X permission (`chmod u+x apple-mouse-keyboard-battery.1m.sh`)
#!/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" = //' |
@petr001
petr001 / iphone-battery-info.1m.sh
Last active February 13, 2023 19:19
Plugin for BitBar to display battery percentage in macOS menu bar when charging your iPhone. Simply download the file and put it to BitBar plugin folder. Remember to install `libimobiledevice` dependency to have it working correctly.
#!/bin/sh
# <bitbar.title>iPhone battery info</bitbar.title>
# <bitbar.version>1.0</bitbar.version>
# IMPORTANT:
# - install libimobiledevice via brew before usage:
# $ brew install --HEAD libimobiledevice
# - tested with only one iphone connected
PATH=$PATH:/usr/local/bin