Miscellaneous Mac Tips

1. Find out what’s keeping your mac awake

pmset is the utility which allows you to configure your system’s power management setings like your system hibernation type (e.g. write data to disk/keep data in ram/do both/disable hibernation) [by the way I have a shell script that makes it easy for you to set your system hibernation type]. But I digress; what I want to share here is how to find out what is keeping your mac from sleeping. Simply use the following command (in the Terminal):

pmset -g assertions

This command displays a range of reasons why your mac can’t sleep “right now” for instance I got this result when “Handoff” was preventing my mac from sleeping.

Example where a process is hindering system sleep.

In the screenshot above we can see the “PreventUserIdleSystemSleep” is “1”, i.e. enabled. And below the command lists the system processes that are causing this.

2. Manage system plugins / extensions.

If you want to check which system plugins are installed &/or running on your mac and want to disable/enable them via CLI you will need to use pluginkit.

  • List all the installed plugins:

    pluginkit -mA 
  • List enabled/disabled plugins:

    # enabled plugins
    pluginkit -mA | grep "+"
    # disabled plugins
    pluginkit -mA | grep "-"
  • Detailed information about a particular plugin:

    Let us search the details of the OneDrive’s Finder Extension that shows the sync status of the files in your OneDrive.

    pluginkit -mAiv com.microsoft.OneDrive.FinderSync
  • Disable a particular plugin:

    Onedrive’s Finder Extension is a resource hog on my macbook pro and the CPU fam ramps up from time to time, eating into my battery life; not to mention the extra heat that is generated. You can easily disable it by running:

    pluginkit -e ignore -i com.microsoft.OneDrive.FinderSync
  • And tying all what we learnt into a one liner, we can disable the extension if it is enabled:

    pluginkit -mi com.microsoft.OneDrive.FinderSync | grep "-"  >/dev/null 2>&1 || { pluginkit -e ignore -i com.microsoft.OneDrive.FinderSync && echo "OneDrive Finder Extension Disabled." }