Skip to content

Instantly share code, notes, and snippets.

@usmanity
Created July 8, 2023 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usmanity/0bada1c88f2da03ca975b5b075d50940 to your computer and use it in GitHub Desktop.
Save usmanity/0bada1c88f2da03ca975b5b075d50940 to your computer and use it in GitHub Desktop.
Script used in Alfred workflow to get battery info for macbooks
cycles=$(system_profiler SPPowerDataType | grep "Cycle Count" | awk '{print $NF}')
maxcap=$(system_profiler SPPowerDataType | grep "Maximum Capacity" | awk '{print $NF}')
condition=$(system_profiler SPPowerDataType | grep "Condition" | awk '{print $NF}')
echo '{
"items": [
{
"uid": "battery-cycles",
"arg": "'"$cycles"'",
"title": "Battery Cycles: '"$cycles"'",
"subtitle": "Copy Battery Cycles to Clipboard",
"icon": {
"path": "icon.png"
}
},
{
"uid": "max-cap",
"arg": "'"$maxcap"'",
"title": "Maximum Capacity: '"$maxcap"'",
"subtitle": "Copy Maximum Capacity to Clipboard",
"icon": {
"path": "icon.png"
}
},
{
"uid": "battery-condition",
"arg": "'"$condition"'",
"title": "Battery Condition: '"$condition"'",
"subtitle": "Copy Battery Condition to Clipboard",
"icon": {
"path": "icon.png"
}
},
]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment