http://i.imgur.com/WGB0Rwv.jpg
根据需求设置定时任务,如 */10 * * * * bash $HOME/.scripts/CheckTrackpadBattery.sh > /dev/null 2>&1
#!/bin/bash
# Create Date: 2017-05-26 17:03:49
# Last Modified: 2017-05-26 17:31:52
# Author: Anton Chen
# Email: [email protected]
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
system_profiler SPBluetoothDataType|grep -A 24 'Devices'|grep -q Trackpad
if [ $? -ne 0 ]; then
echo "Trackpad 未连接"
exit 1
fi
batteryLevel=$(system_profiler SPBluetoothDataType|grep -A 24 'Devices'|grep Battery|awk -F"[:| |%]+" '{print $4}')
if [ $batteryLevel -lt 20 ]; then
osascript -e "tell application \"System Events\" to display notification \"电量低,剩余 $batteryLevel%\" with title \"Magic Trackpad 2\" sound name \"Submarine\""
fi
https://github.com/antonchen/scripts/blob/master/macOS/CheckTrackpadBattery.sh
1
chairuosen 2017-05-26 17:57:12 +08:00
........topbar 蓝牙的下拉菜单里能看电量的
|
2
AntonChen OP @chairuosen 电量低有提示么?我没发现有。
|
3
chairuosen 2017-05-26 18:04:55 +08:00
@AntonChen 触摸板有没有我没印象了,不过蓝牙鼠标键盘电量低是有提示的,触摸板应该也有
|
5
maemolee 2017-05-27 00:27:38 +08:00
触摸板和键盘在 10%左右电量(左右)就会推送充电通知的。
|