How to Use the Command `pmset` (with Examples)

How to Use the Command `pmset` (with Examples)

  • Osx
  • December 17, 2024

The pmset command is a powerful tool available in macOS that allows users to configure power management settings directly from the command line. It provides functionality equivalent to what is found in the System Preferences under the Energy Saver section. With pmset, users can view and modify various power-related configurations, tailor power usage based on power sources, schedule system sleep and wake times, and much more. This tool is particularly useful for advanced users or system administrators who manage multiple machines or need to automate power management tasks. Below are some practical examples illustrating the capabilities of pmset.

Display the Current Power Management Settings

Code:

pmset -g

Motivation:

This command is useful for users who want to review the current power management settings configured on their macOS device. Knowing these settings can provide insight into how the system is managing power, which can be crucial for optimizing performance or battery usage.

Explanation:

  • -g: This option stands for ‘get’ and is used to display the current settings. It retrieves all the power management parameters currently configured on the system, allowing the user to evaluate existing configurations.

Example Output:

Active Profiles:
 Battery Power       -1
 AC Power            2*
Currently in use:
 standby              1
 halfdim              1
  acwake               0
 lidwake              1

Display the Current Power Source and Battery Levels

Code:

pmset -g batt

Motivation:

This command is helpful for users interested in monitoring their device’s power source and battery level, especially useful for managing battery health and ensuring efficient energy usage on a laptop.

Explanation:

  • -g batt: This is a specific ‘get’ command that focuses on battery-related information. It shows the current power source (whether the device is plugged into a charger or using battery) and the percentage charge of the battery.

Example Output:

Now drawing from 'Battery Power'
 -InternalBattery-0 (id=1234567)    90%; discharging; (no estimate)

Put Display to Sleep Immediately

Code:

pmset displaysleepnow

Motivation:

This command is immediately useful for conserving energy or privacy when you need to quickly put your display to sleep, especially in public spaces or when stepping away from your desk.

Explanation:

  • displaysleepnow: This argument tells the system to put the display to sleep immediately without affecting other settings or waiting for any timers.

Example Output:

No textual output is generated, as the display will turn off upon execution.

Set Display to Never Sleep When on Charger Power

Code:

sudo pmset -c displaysleep 0

Motivation:

For users who need to keep their display on continually when plugged into a power source, such as during presentations, collaborations, or when using the Mac as a monitor, this command is essential.

Explanation:

  • sudo: Superuser privileges are required to change system settings.
  • -c: Refers to ‘charger’ power source.
  • displaysleep 0: Sets the display sleep timer to 0, meaning the display will not automatically turn off while the Mac is charging.

Example Output:

- Current setting indicates that the display will remain on indefinitely while connected to a charger. 

Set Display to Sleep After 15 Minutes When on Battery Power

Code:

sudo pmset -b displaysleep 15

Motivation:

Ideal for saving battery life, this command ensures the display turns off after a period of inactivity when the laptop is running on battery, thus conserving energy.

Explanation:

  • sudo: Required to execute the command with administrative privileges.
  • -b: Refers to ‘battery’ power source.
  • displaysleep 15: Sets the display to sleep after 15 minutes of inactivity on battery power.

Example Output:

- Setting update shows the display will automatically sleep after 15 minutes on battery power.

Schedule Computer to Automatically Wake Up Every Weekday at 9 AM

Code:

sudo pmset repeat wake MTWRF 09:00:00

Motivation:

For routine users or work environments, scheduling computers to wake up at a designated time can streamline the start of the workday, ensuring the device is ready for use without manual intervention.

Explanation:

  • sudo: Superuser access is needed to apply scheduled tasks.
  • repeat: Keyword to define recurring events.
  • wake MTWRF 09:00:00: Sets the system to wake from sleep on Monday through Friday at 9 AM.

Example Output:

- The system is now scheduled to wake up every weekday at 9 AM.

Restore to System Defaults

Code:

sudo pmset -a displaysleep 10 disksleep 10 sleep 30 womp 1

Motivation:

Restoring default power settings is valuable for troubleshooting or returning a system to a known baseline after modifications have been made. It is particularly useful for users experiencing issues with custom power settings or poor performance.

Explanation:

  • sudo: Administrative privileges are required.
  • -a: Applies settings to all power sources.
  • displaysleep 10: Sets the display to sleep after 10 minutes.
  • disksleep 10: Puts the disk to sleep after 10 minutes.
  • sleep 30: Enables system sleep after 30 minutes of inactivity.
  • womp 1: Enables Wake on LAN, which is useful for remote desktop management.

Example Output:

- System power management settings reset to defaults: display sleeps after 10 mins, disk sleeps after 10 mins, system sleeps after 30 mins, Wake-on-LAN enabled.

Conclusion

The pmset command offers extensive control over power management on macOS, allowing users to tailor settings to different usage scenarios. From adjusting sleep settings based on power source, monitoring battery information, automating schedules, to restoring defaults, pmset is a versatile tool that can enhance the efficiency and battery health of a Mac device. Whether for individual use or in a managed IT environment, becoming proficient with pmset can lead to improved energy management and device performance.

Tags :

Related Posts

How to use the command 'kubectl logs' (with examples)

How to use the command 'kubectl logs' (with examples)

In Kubernetes, pods are the smallest deployable units that can be created and managed.

Read More
How to Use the Command 'xcv' (with examples)

How to Use the Command 'xcv' (with examples)

The xcv command is a versatile tool designed for cut, copy, and paste actions in the command-line environment.

Read More
How to use the command 'dmesg' (with examples)

How to use the command 'dmesg' (with examples)

The dmesg command is a diagnostic tool that prints messages from the kernel’s message buffer.

Read More