Created
June 9, 2023 06:48
-
-
Save hyoban/1f6ab00696ce810160fbbca3d9b2226a 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/bash | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title Battery Notification | |
# @raycast.mode inline | |
# @raycast.refreshTime 30s | |
# Optional parameters: | |
# @raycast.icon 🔋 | |
# Documentation: | |
# @raycast.author hyoban | |
# @raycast.authorURL https://raycast.com/hyoban | |
battery_percentage=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) | |
dis_charging=$(pmset -g batt | grep -Eo "discharging") | |
if [ $battery_percentage -lt 30 ] && [ $dis_charging ]; then | |
osascript -e 'display notification "电量还剩 '$battery_percentage'%" with title "快来充电啊"' | |
fi | |
if [ $battery_percentage -gt 80 ] && [ ! $dis_charging ]; then | |
osascript -e 'display notification "电量还剩 '$battery_percentage'%" with title "电量充足, 可以拔掉电源了"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment