4

Every time I add a few MBss of files to my SD disk, Spotlight starts eating battery (per Activity Monitor Energy Impact) for one to several days indexing them.

How can I make indexing to turn off automatically when on battery power, and enable again when Macbook is powered from an AC outlet?

4

jherran's answer helps you with disabling Spotlight indexing, but does not address the part of the question about toggling automatically when AC power is connected or disconnected.

You could use sudo mdutil -i off / and sudo mdutil -i on / in conjunction with a listener for when AC power is disconnected. Using something like ControlPlane will satisfy your requirement for automatic toggling. It supports "Current power source" as an event to listen for. It is free and open source.

You might be against using a third party solution. To roll your own, try writing a script that loops checking pmset -g ps | grep -c 'AC Power' with a sleep interval in between. If AC is connected, it outputs 1 (0 otherwise).

  • I would be grateful for a sample scrip doing just that for no-third-party case. And I failed to make ControlPlane work correctly for this purpose. – yurkennis Mar 16 '15 at 15:29
0

Open your Terminal and type the following to disable.

sudo mdutil -i off /

To enable again, replace off with on.

For more info, you could type:

man mdutil
  • As @aglasser suggests, your answer "does not address the part of the question about toggling automatically when AC power is connected or disconnected". Hence the downvote. – yurkennis Oct 31 '14 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .