Created
July 8, 2023 04:17
-
-
Save usmanity/0bada1c88f2da03ca975b5b075d50940 to your computer and use it in GitHub Desktop.
Script used in Alfred workflow to get battery info for macbooks
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
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