I want to run a bash script on my jailbroken iPhone whenever it is being charged. Currently my script looks like this:
#!/bin/bash ACpower=$(pmset -g | sed -n '2 p' | grep -o '*') if [ "$ACpower" != "*" ]; then exit 0 fi rest of script...
As you can see I'm using the pmset package to basically output a list of different variables and then extract the * which indicates if it is being charged or not. If it is not being charged the script stops, otherwise it continues with the rest of it.
Next I was thinking of adding this to a launchdaemon to basically run this script at a given interval.
However, that also gives rise to my question for you guys: If I run this command say every 15 or 30 seconds will that have a noticeable impact on my battery life? Or is there a better way to monitor this variable change than letting the script be ran at an interval?