Opt
public enum Opt
A customization option for a Caffeination.
Note
Any givenCaffeination can be passed only one of each Opt. So, for instance, it is valid to pass a .timed and .process Opt; however, it is not possible to have two different .process Opts.
-
Prevents disk idle sleep.
Declaration
Swift
case disk -
Prevents display sleep.
Declaration
Swift
case display -
Prevents system idle sleep.
Declaration
Swift
case idle -
Prevents system sleep.
Note
On MacBooks, will only work when connected to AC power.Declaration
Swift
case system -
Simulates user activity to keep display awake.
Note
caffeinateshould automatically timeout after 5 seconds if.timedis not also selected. However, due to a bug in thecaffeinatetool, this does not currently happen, and the process will continue indefinitely.Declaration
Swift
case user -
Terminates Caffeination when process with specified PID exits. Might be preempted by
.timed.Declaration
Swift
case process(Int32) -
Terminates Caffeination after specified period of time in seconds. Might be preempted by
.process.Declaration
Swift
case timed(TimeInterval) -
The default options for a standard Caffeination.
Declaration
Swift
public static var defaults: [Opt] { get } -
Converts an Opt to the raw argument(s) passed to caffeinate.
Declaration
Swift
public var argumentList: [String] { get } -
Returns an
Optcorresponding to a single caffeinate argument string.Note
Options that require a numerical argument (e.g.,-t) should usefrom(_ array:).Declaration
Swift
public static func from(_ string: String) -> Opt?Parameters
stringThe String containing the argument to parse.
Return Value
An
Optcorresponding to the argument passed, ornilif the argument was not recognized. -
Returns an
Optfrom a [String] containing a single argument to caffeinate and, if necessary, an associated numerical argument.Note
nilwill be returned if:- an unknown argument is passed (e.g.,
["-f"]). - a value is passed for an argument that doesn’t accept one (e.g.,
["-m", "42"]). - no value is passed for an argument that requires one (e.g.,
["-w"]). - multiple option arguments are passed (e.g.,
["-d", "-m"]) (usearray(from:)instead).
Declaration
Swift
public static func from(_ array: [String]) -> Opt?Parameters
arrayThe array containing the single argument to caffeinate and an associated value (if necessary).
Return Value
An
Optcorresponding to the argument, ornil. - an unknown argument is passed (e.g.,
-
Returns an [Opt] from a [String] containing raw arguments (and their associated integer values, if needed) to caffeinate, or
nilif an invalid value is passed (see discussion).Note
nilwill be returned if:- an unknown argument is passed (e.g.,
["-f"]). - a value is passed for an argument that doesn’t accept one (e.g.,
["-m", "42"]). - no value is passed for an argument that requires one (e.g.,
["-w", "-d"]).
Declaration
Swift
public static func array(from stringArray: [String]) -> [Opt]?Parameters
stringArrayThe array from which to parse the argument (and associated value).
Return Value
An array of
Opts corresponding to the values passed, ornil. - an unknown argument is passed (e.g.,
View on GitHub
Install in Dash
Opt Enumeration Reference