mjolnir.cmsj.caffeinate
Prevent various kinds of sleep activities in OSX
Usage:
local caffeinate = require "mjolnir.cmsj.caffeinate"
NOTE: Any sleep preventions will be removed when mjolnir.reload() is called. A future version of the module will save/restore state across reloads.
mjolnir.cmsj.caffeinate.get(sleepType) -> bool or nil
Queries whether a particular sleep type is being prevented by Mjolnir.
Arguments:
- sleepType (string): (see set for information about these values)
- DisplayIdle
- SystemIdle
- System
Returns:
- true - if the specified sleepType is currently being prevented.
- false - if the specified sleepType is not currenly being prevented.
- nil - if an invalid sleepType is specified.
mjolnir.cmsj.caffeinate.set(sleepType, aValue, AC_and_battery)
Configures the sleep prevention settings.
Arguments:
- sleepType (string):
- DisplayIdle - Controls whether the screen will be allowed to sleep (and also the system) if the user is idle.
- SystemIdle - Controls whether the system will be allowed to sleep if the user is idle (display may still sleep).
- System - Controls whether the system will be allowed to sleep for any reason.
- aValue (boolean):
- True - The specified sleep type should be prevented.
- False - The specified sleep type should be allowed.
- acAndBattery (boolean):
- True - System should not sleep when on AC or battery.
- False - System should not sleep only when on AC.
NOTES:
- These calls are not guaranteed to prevent the system sleep behaviours described above. The OS may override them if it feels it must (e.g. if your CPU temperature becomes dangerously high).
- The acAndBattery argument only applies to the "System" sleep type.
- You can toggle the acAndBattery state by calling set() again and altering the AC_and_battery value.
mjolnir.cmsj.caffeinate.toggle(sleepType) -> bool or nil
Toggles the current state of the specified sleepType.
Arguments:
- sleepType (string): (see set for information about these values)
- DisplayIdle
- SystemIdle
- System
Returns:
- true - if the new state of sleepType is prevention.
- false - if the new state of sleepType is allowance.
- nil - if an invalid sleepType is specified.
NOTE: If SystemIdle is toggled to on, it will apply to AC only.