InsomniaX is a free Mac app that not only lets you disable Mac’s idle sleep function, but also lets you stop your MacBook from entering sleep mode when you close the lid. The app lets you define these settings based on the power source, i.e., if the MacBook is running on battery, you may choose to allow it to enter sleep mode when the lid closes or the system is idle, and disable this behavior when it is plugged in.
Once installed, the app adds a dark crescent button to the Menu Bar. From the app’s Menu Bar icon, you can quickly choose to enable or disable sleep on lid close or if idle. You can also put the system to sleep immediately by selecting Sleep Display. To stop the system from entering sleep when the lid closes, selectDisable Lid Sleep. To restore the functionality, visit the same menu and select Enable Lid Sleep. Follow suit to disable sleeping on system idle.
The app’s preferences, which can be found within the app’s Menu Bar options, allow you to choose if the system should sleep when the lid is closed if it is on battery or plugged in. Go to Preferences > Disable Lid Sleep on…> Battery or Preferences > Disable Lid Sleep on…> AC. Similar options exist to customize the “sleep if idle” behavior.
The app has an additional feature called CPU Safety, which, if enabled, will put your MacBook to sleep if the CPU core temperature reaches or exceeds 90 degrees. You can have the app remember your preferences by selecting Save states on exit, and enable it to start when you login to your system.
The app is useful mostly if you want to disable the lid from putting your MacBook to sleep. If you only want to stop your system from going to sleep if it is idle, you can do so from System Preferences > Energy Saver.