salt.modules.mac_power module

Module for editing power settings on macOS

New in version 2016.3.0.

salt.modules.mac_power.get_computer_sleep()

Display the amount of idle time until the computer sleeps.

Returns

A string representing the sleep settings for the computer

Return type

str

CLI Example:

..code-block:: bash

salt '*' power.get_computer_sleep

salt.modules.mac_power.get_display_sleep()

Display the amount of idle time until the display sleeps.

Returns

A string representing the sleep settings for the displey

Return type

str

CLI Example:

..code-block:: bash

salt '*' power.get_display_sleep

salt.modules.mac_power.get_harddisk_sleep()

Display the amount of idle time until the hard disk sleeps.

Returns

A string representing the sleep settings for the hard disk

Return type

str

CLI Example:

..code-block:: bash

salt '*' power.get_harddisk_sleep

salt.modules.mac_power.get_restart_freeze()

Displays whether 'restart on freeze' is on or off if supported

Returns

A string value representing the "restart on freeze" settings

Return type

string

CLI Example:

salt '*' power.get_restart_freeze
salt.modules.mac_power.get_restart_power_failure()

Displays whether 'restart on power failure' is on or off if supported

Returns

A string value representing the "restart on power failure" settings

Return type

string

CLI Example:

salt '*' power.get_restart_power_failure
salt.modules.mac_power.get_sleep()

Displays the amount of idle time until the machine sleeps. Settings for Computer, Display, and Hard Disk are displayed.

Returns

A dictionary containing the sleep status for Computer, Display, and Hard Disk

Return type

dict

CLI Example:

salt '*' power.get_sleep
salt.modules.mac_power.get_sleep_on_power_button()

Displays whether 'allow power button to sleep computer' is on or off if supported

Returns

A string value representing the "allow power button to sleep computer" settings

Return type

string

CLI Example:

salt '*' power.get_sleep_on_power_button
salt.modules.mac_power.get_wake_on_modem()

Displays whether 'wake on modem' is on or off if supported

Returns

A string value representing the "wake on modem" settings

Return type

str

CLI Example:

salt '*' power.get_wake_on_modem
salt.modules.mac_power.get_wake_on_network()

Displays whether 'wake on network' is on or off if supported

Returns

A string value representing the "wake on network" settings

Return type

string

CLI Example:

salt '*' power.get_wake_on_network
salt.modules.mac_power.set_computer_sleep(minutes)

Set the amount of idle time until the computer sleeps. Pass "Never" of "Off" to never sleep.

Parameters

minutes -- Can be an integer between 1 and 180 or "Never" or "Off"

Ptype

int, str

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_computer_sleep 120
salt '*' power.set_computer_sleep off
salt.modules.mac_power.set_display_sleep(minutes)

Set the amount of idle time until the display sleeps. Pass "Never" of "Off" to never sleep.

Parameters

minutes -- Can be an integer between 1 and 180 or "Never" or "Off"

Ptype

int, str

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_display_sleep 120
salt '*' power.set_display_sleep off
salt.modules.mac_power.set_harddisk_sleep(minutes)

Set the amount of idle time until the harddisk sleeps. Pass "Never" of "Off" to never sleep.

Parameters

minutes -- Can be an integer between 1 and 180 or "Never" or "Off"

Ptype

int, str

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_harddisk_sleep 120
salt '*' power.set_harddisk_sleep off
salt.modules.mac_power.set_restart_freeze(enabled)

Specifies whether the server restarts automatically after a system freeze. This setting doesn't seem to be editable. The command completes successfully but the setting isn't actually updated. This is probably a macOS. The functions remains in case they ever fix the bug.

Parameters

enabled (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_restart_freeze True
salt.modules.mac_power.set_restart_power_failure(enabled)

Set whether or not the computer will automatically restart after a power failure.

Parameters

enabled (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_restart_power_failure True
salt.modules.mac_power.set_sleep(minutes)

Sets the amount of idle time until the machine sleeps. Sets the same value for Computer, Display, and Hard Disk. Pass "Never" or "Off" for computers that should never sleep.

Parameters

minutes -- Can be an integer between 1 and 180 or "Never" or "Off"

Ptype

int, str

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_sleep 120
salt '*' power.set_sleep never
salt.modules.mac_power.set_sleep_on_power_button(enabled)

Set whether or not the power button can sleep the computer.

Parameters

enabled (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_sleep_on_power_button True
salt.modules.mac_power.set_wake_on_modem(enabled)

Set whether or not the computer will wake from sleep when modem activity is detected.

Parameters

enabled (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_wake_on_modem True
salt.modules.mac_power.set_wake_on_network(enabled)

Set whether or not the computer will wake from sleep when network activity is detected.

Parameters

enabled (bool) -- True to enable, False to disable. "On" and "Off" are also acceptable values. Additionally you can pass 1 and 0 to represent True and False respectively

Returns

True if successful, False if not

Return type

bool

CLI Example:

salt '*' power.set_wake_on_network True