-
Notifications
You must be signed in to change notification settings - Fork 2
/
sleepwatcher_manual.html
292 lines (226 loc) · 10.2 KB
/
sleepwatcher_manual.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!-- Creator : groff version 1.19.2 -->
<!-- CreationDate: Sun May 19 13:26:33 2019 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; }
pre { margin-top: 0; margin-bottom: 0; }
table { margin-top: 0; margin-bottom: 0; }
</style>
<title></title>
</head>
<body>
<hr>
<p valign="top">sleepwatcher(8) BSD System Manager’s
Manual sleepwatcher(8)</p>
<p style="margin-top: 1em" valign="top"><b>NAME</b></p>
<p style="margin-left:8%;"><b>sleepwatcher</b> —
daemon to monitor sleep, wakeup and idleness of a Mac</p>
<p style="margin-top: 1em" valign="top"><b>SYNOPSIS</b></p>
<p style="margin-left:28%;"><b>sleepwatcher</b>
[<b>−n</b>] [<b>−v</b>] [<b>−V</b>]
[<b>−d</b>] [<b>−g</b>]
[<b>−f </b><i>configfile</i>]
[<b>−p </b><i>pidfile</i>] [</p>
<p valign="top"><b>−a</b>[allowsleepcommand] ]
[<b>−c </b><i>cantsleepcommand</i>]
[<b>−s </b><i>sleepcommand</i>]
[<b>−w </b><i>wakeupcommand</i>]
[<b>−D </b><i>displaydimcommand</i>]
[<b>−E </b><i>displayundimcommand</i>]
[<b>−S </b><i>displaysleepcommand</i>]
[<b>−W </b><i>displaywakeupcommand</i>] [ <b><br>
−t</b> <i>timeout</i> <b>−i</b>
<i>idlecommand</i>
[<b>−R </b><i>idleresumecommand</i>] ]
[<b>−b </b><i>break </i><b>−r </b><i>resumecommand</i>]
[<b>−P </b><i>plugcommand</i>]
[<b>−U </b><i>unplugcommand</i>]</p>
<p style="margin-top: 1em" valign="top"><b>DESCRIPTION</b></p>
<p style="margin-left:8%;"><b>sleepwatcher</b> is a program
that monitors sleep, wakeup and idleness of a Mac. It can be
used to execute a Unix command when the Mac or the display
of the Mac goes to sleep mode or wakes up, after a given
time without user interaction or when the user resumes
activity after a break or when the power supply of a Mac
notebook is attached or detached. It also can send the Mac
to sleep mode or retrieve the time since last user
activity.</p>
<p style="margin-left:8%; margin-top: 1em">Command line
options:</p>
<p style="margin-top: 1em" valign="top"><b>−n</b>,
<b>−−now</b></p>
<p style="margin-left:22%;">Sleep now and exit, ignoring
other options.</p>
<p style="margin-top: 1em" valign="top"><b>−v</b>,
<b>−−version</b></p>
<p style="margin-left:22%;">Display version and copyright
information and exit.</p>
<p style="margin-top: 1em" valign="top"><b>−V</b>,
<b>−−verbose</b></p>
<p style="margin-left:22%;">Log any action
<b>sleepwatcher</b> performs, either to stdout or, when
running as daemon, to the syslog.</p>
<p style="margin-top: 1em" valign="top"><b>−d</b>,
<b>−−daemon</b></p>
<p style="margin-left:22%;">Run as background daemon.
Don’t use this option when starting
<b>sleepwatcher</b> via launchd(8).</p>
<p style="margin-top: 1em" valign="top"><b>−g</b>,
<b>−−getidletime</b></p>
<p style="margin-left:22%;">Print the time (in 0.1 seconds)
of no keyboard or mouse activity to stdout and exit,
ignoring other options.</p>
<p style="margin-top: 1em" valign="top"><b>−f</b>
<i>configfile</i>, <b>−−config</b>
<i>configfile</i></p>
<p style="margin-left:22%;">Read additional configuration
options from <i>configfile</i>. <i>configfile</i> contains
options in the form <b>option [ = value ]</b> where
<b>option</b> is one of the long command line options
(without --). <b>sleepwatcher</b> rereads its configuration
file when it receives a hangup signal, SIGHUP.</p>
<p style="margin-top: 1em" valign="top"><b>−p</b>
<i>pidfile</i>, <b>−−pidfile</b>
<i>pidfile</i></p>
<p style="margin-left:22%;">Write the process id of
<b>sleepwatcher</b> to <i>pidfile</i>.</p>
<p style="margin-top: 1em" valign="top"><b>−a</b>[
<i><br>
allowsleepcommand</i>],
<b>−−allowsleep</b>[=<i>allowsleepcommand</i>]</p>
<p style="margin-left:22%;">Allow the Mac to idle sleep
only when <i>allowsleepcommand</i> returns a zero exit code.
Without <i>allowsleepcommand</i>, this option prevents idle
sleep at all. When the <b>−a</b> option is not used at
all, <b>sleepwatcher</b> allows idle sleep unconditionally.
(Note: no space after the <b>-a</b>.)</p>
<p style="margin-top: 1em" valign="top"><b>−c</b>
<i>cantsleepcommand</i>, <b>−−cantsleep</b>
<i>cantsleepcommand</i></p>
<p style="margin-left:22%;">Execute <i>cantsleepcommand</i>
when the Mac retracts an attempt to sleep that was
previously allowed by the <b>-a</b> option, but vetoed by
another process that wants to prevent idle sleep. Note that
the kernel notifies <b>sleepwatcher</b> about the retracted
sleep only when it previously asked it if sleeping is
allowed. There might be canceled idle sleep attempts without
the <b>-a</b> and <b>-c</b> commands executed at all.</p>
<p style="margin-top: 1em" valign="top"><b>−s</b>
<i>sleepcommand</i>, <b>−−sleep</b>
<i>sleepcommand</i></p>
<p style="margin-left:22%;">Execute <i>sleepcommand</i>
when the Mac is put to sleep mode. <i>sleepcommand</i> must
not take longer than 15 seconds because after this timeout
the sleep mode is forced by the system.</p>
<p style="margin-top: 1em" valign="top"><b>−w</b>
<i>wakeupcommand</i>, <b>−−wakeup</b>
<i>wakeupcommand</i></p>
<p style="margin-left:22%;">Execute <i>wakeupcommand</i>
when the Mac wakes up from sleep mode.</p>
<p style="margin-top: 1em" valign="top"><b>−D</b>
<i>displaydimcommand,</i> <b>−−displaydim</b>
<i>displaydimcommand</i></p>
<p style="margin-left:22%;">Execute
<i>displaydimcommand</i> when the display of the Mac is
dimmed. Note that the <i>displaydimcommand</i> is executed
when the Mac goes to sleep mode, too.</p>
<p style="margin-top: 1em" valign="top"><b>−E</b>
<i>displayundimcommand,</i>
<b>−−displayundim</b>
<i>displayundimcommand</i></p>
<p style="margin-left:22%;">Execute
<i>displayundimcommand</i> when the display of the Mac is
undimmed without having gone to sleep. Note that the
<i>displayundimcommand</i> is not executed when the Mac or
the display of the Mac wakes up from sleep mode.</p>
<p style="margin-top: 1em" valign="top"><b>−S</b>
<i>displaysleepcommand,</i>
<b>−−displaysleep</b>
<i>displaysleepcommand</i></p>
<p style="margin-left:22%;">Execute
<i>displaysleepcommand</i> when the display of the Mac is
put to sleep mode.</p>
<p style="margin-top: 1em" valign="top"><b>−W</b>
<i>displaywakeupcommand,</i>
<b>−−displaywakeup</b>
<i>displaywakeupcommand</i></p>
<p style="margin-left:22%;">Execute
<i>displaywakeupcommand</i> when the display of the Mac
wakes up from sleep mode. Note that the
<i>displaywakeupcommand</i> is executed when the Mac wakes
up from sleep mode, too.</p>
<p style="margin-top: 1em" valign="top"><b>−t</b>
<i>timeout</i>, <b>−−timeout</b>
<i>timeout</i></p>
<p style="margin-left:22%;">Set the <i>timeout</i> (in 0.1
seconds) for the <b>-i</b> option, i. e. execute
<i>idlecommand</i> after this time of no user
interactivity.</p>
<p style="margin-top: 1em" valign="top"><b>−i</b>
<i>idlecommand</i>, <b>−−idle</b>
<i>idlecommand</i></p>
<p style="margin-left:22%;">Execute <i>idlecommand</i>
after the time of no user interactivity set with the
<b>-t</b> option.</p>
<p style="margin-top: 1em" valign="top"><b>−R</b>
<i>idleresumecommand,</i> <b>−−idleresume</b>
<i>idleresumecommand</i></p>
<p style="margin-left:22%;">Execute
<i>idleresumecommand</i> when the user resumes input after
the <b>-i</b> command was executed due to an idle time.</p>
<p style="margin-top: 1em" valign="top"><b>−b</b>
<i>breakduration</i>, <b>−−break</b>
<i>breakduration</i></p>
<p style="margin-left:22%;">Set the <i>breakduration</i>
(in 0.1 seconds) for the <b>-r</b> option, i. e. execute
<i>resumecommand</i> when the user resumes input after a
break of at least this duration.</p>
<p style="margin-top: 1em" valign="top"><b>−r</b>
<i>resumecommand</i>, <b>−−resume</b>
<i>resumecommand</i></p>
<p style="margin-left:22%;">Execute <i>resumecommand</i>
when the user resumes keyboard or mouse activity after a
break with a duration given with the <b>-b</b> option.</p>
<p style="margin-top: 1em" valign="top"><b>−P</b>
<i>plugcommand</i>, <b>−−plug</b>
<i>plugcommand</i></p>
<p style="margin-left:22%;">Execute <i>plugcommand</i> when
a Mac notebook is connected to the power supply.</p>
<p style="margin-top: 1em" valign="top"><b>−U</b>
<i>unplugcommand</i>, <b>−−unplug</b>
<i>unplugcommand</i></p>
<p style="margin-left:22%;">Execute <i>unplugcommand</i>
when a Mac notebook is disconnected from the power
supply.</p>
<p style="margin-top: 1em" valign="top"><b>SEE ALSO</b></p>
<p style="margin-left:8%;">pmset(1), launchd(8),
SystemStarter(8)</p>
<p style="margin-top: 1em" valign="top"><b>BUGS</b></p>
<p style="margin-left:8%;">The <b>-t -i</b> and <b>-b
-r</b> options only work when the Mac OS X GUI is running,
so they cannot be used when <b>sleepwatcher</b> is started
as a system-wide launchd(8) agent during system startup.</p>
<p style="margin-left:8%; margin-top: 1em">Any user with
execute permission for <b>sleepwatcher</b> can send the Mac
to sleep mode with the <b>-n</b> option, making the system
unavailable for other (remote) users.</p>
<p style="margin-top: 1em" valign="top"><b>ACKNOWLEDGEMENTS</b></p>
<p style="margin-left:8%;">Thanks to Daniel Griscom for the
idea and code for the deny sleep feature. Thanks to Darren
Creutz for the idea and code for the display sleep support.
Thanks to Michael Lee for the ideas for idleness handling
within <b>sleepwatcher</b>. Thanks to Brian Jenkins for the
idea and code for the power supply feature. And thanks to
Louis Pan for the idea and code for the can’t sleep
callback.</p>
<p style="margin-left:8%; margin-top: 1em">Darwin
May 19, 2019 Darwin</p>
<hr>
</body>
</html>