http://ftp.ksu.edu.tw/FTP/FreeBSD/distfiles/xscreensaver-4.20.tar.gz
[xscreensaver] / driver / xscreensaver-command.man
1 .de EX          \"Begin example
2 .ne 5
3 .if n .sp 1
4 .if t .sp .5
5 .nf
6 .in +.5i
7 ..
8 .de EE
9 .fi
10 .in -.5i
11 .if n .sp 1
12 .if t .sp .5
13 ..
14 .TH XScreenSaver 1 "23-Feb-2005 (4.20)" "X Version 11"
15 .SH NAME
16 xscreensaver-command - control a running xscreensaver process
17 .SH SYNOPSIS
18 .B xscreensaver-command
19 [\-display \fIhost:display.screen\fP] \
20 [\-help | \
21 \-demo | \
22 \-prefs | \
23 \-activate | \
24 \-deactivate | \
25 \-cycle | \
26 \-next | \
27 \-prev | \
28 \-select \fIn\fP | \
29 \-exit | \
30 \-restart | \
31 \-lock | \
32 \-version | \
33 \-time | \
34 \-watch]
35 .SH DESCRIPTION
36 The \fIxscreensaver\-command\fP program controls a running \fIxscreensaver\fP
37 process by sending it client-messages.
38
39 .BR xscreensaver (1)
40 has a client-server model: the xscreensaver process is a
41 daemon that runs in the background; it is controlled by other
42 foreground programs such as \fIxscreensaver-command\fP and
43 .BR xscreensaver\-demo (1).
44
45 This program, \fIxscreensaver-command\fP, is a command-line-oriented tool; the 
46 .BR xscreensaver\-demo (1).
47 program is a graphical tool.
48 .SH OPTIONS
49 .I xscreensaver-command
50 accepts the following command-line options:
51 .TP 8
52 .B \-help
53 Prints a brief summary of command-line options.
54 .TP 8
55 .B \-demo
56 This just launches the
57 .BR xscreensaver\-demo (1)
58 program, in which one can experiment with the various graphics hacks
59 available, and edit parameters.
60 .TP 8
61 .B \-demo \fP\fInumber\fP
62 When the \fI\-demo\fP option is followed by an integer, it instructs 
63 the \fIxscreensaver\fP daemon to run that hack, and wait for the user
64 to click the mouse before deactivating (i.e., mouse motion does not
65 deactivate.)  This is the mechanism by which
66 .BR xscreensaver\-demo (1)
67 communicates with the
68 .BR xscreensaver (1)
69 daemon.  (The first hack in the list is numbered 1, not 0.)
70 .TP 8
71 .B \-prefs
72 Like the no-argument form of \fI\-demo\fP, but brings up that program's
73 Preferences panel by default.
74 .TP 8
75 .B \-activate
76 Tell xscreensaver to turn on immediately (that is, blank the screen, as if
77 the user had been idle for long enough.)  The screensaver will deactivate as
78 soon as there is any user activity, as usual.
79
80 It is useful to run this from a menu; you may wish to run it as
81 .EX
82 sleep 5 ; xscreensaver-command -activate
83 .EE
84 to be sure that you have time to take your hand off the mouse before
85 the screensaver comes on.  (Because if you jiggle the mouse, xscreensaver
86 will notice, and deactivate.)
87 .TP 8
88 .B \-deactivate
89 This tells xscreensaver to pretend that there has just been user activity.
90 This means that if the screensaver is active (the screen is blanked),
91 then this command will cause the screen to un-blank as if there had been
92 keyboard or mouse activity.  If the screen is locked, then the password
93 dialog will pop up first, as usual.  If the screen is not blanked, then
94 this simulated user activity will re-start the countdown (so, issuing
95 the \fI\-deactivate\fP command periodically is \fIone\fP way to prevent
96 the screen from blanking.)
97 .TP 8
98 .B \-cycle
99 If the screensaver is active (the screen is blanked), then stop the current
100 graphics demo and run a new one (chosen randomly.)
101 .TP 8
102 .B \-next
103 This is like either \fI\-activate\fP or \fI\-cycle\fP, depending on which is
104 more appropriate, except that the graphics hack that will be run is the next
105 one in the list, instead of a randomly-chosen one.  In other words, 
106 repeatedly executing -next will cause the xscreensaver process to invoke each
107 graphics demo sequentially.  (Though using the \fI\-demo\fP option is probably
108 an easier way to accomplish that.)
109 .TP 8
110 .B \-prev
111 This is like \fI\-next\fP, but cycles in the other direction.
112 .TP 8
113 .B \-select \fInumber\fP
114 Like \fI\-activate\fP, but runs the \fIN\fPth element in the list of hacks.
115 By knowing what is in the \fIprograms\fP list, and in what order, you can use
116 this to activate the screensaver with a particular graphics demo.  (The first
117 element in the list is numbered 1, not 0.)
118 .TP 8
119 .B \-exit
120 Causes the xscreensaver process to exit gracefully.  This is roughly the same
121 as killing the process with
122 .BR kill (1),
123 but it is easier, since you don't need to first figure out the pid.  
124
125 .B Warning:
126 never use \fIkill -9\fP with \fIxscreensaver\fP while the screensaver is
127 active.  If you are using a virtual root window manager, that can leave
128 things in an inconsistent state, and you may need to restart your window
129 manager to repair the damage.
130 .TP 8
131 .B \-lock
132 Tells the running xscreensaver process to lock the screen immediately.  
133 This is like \fI\-activate\fP, but forces locking as well, even if locking
134 is not the default (that is, even if xscreensaver's \fIlock\fP resource is
135 false, and even if the \fIlockTimeout\fP resource is non-zero.)
136
137 Note that locking doesn't work unless the \fIxscreensaver\fP process is
138 running as you.  See 
139 .BR xscreensaver (1)
140 for details.
141 .TP 8
142 .B \-version
143 Prints the version of xscreensaver that is currently running on the display:
144 that is, the actual version number of the running xscreensaver background 
145 process, rather than the version number of xscreensaver-command.  (To see
146 the version number of \fIxscreensaver-command\fP itself, use 
147 the \fI\-help\fP option.)
148 .TP 8
149 .B \-time
150 Prints the time at which the screensaver last activated or 
151 deactivated (roughly, how long the user has been idle or non-idle: but 
152 not quite, since it only tells you when the screen became blanked or
153 un-blanked.)
154 .TP 8
155 .B \-restart
156 Causes the screensaver process to exit and then restart with the same command
157 line arguments as last time.  Do this after you've changed the resource
158 database, to cause xscreensaver to notice the changes.
159
160 .B Warning:
161 if you have a \fI.xscreensaver\fP file, this might not do what you 
162 expect.  You're probably better off killing the existing 
163 xscreensaver (with \fIxscreensaver\-command -exit\fP) and then
164 launching it again.
165
166 The important point is, you need to make sure that the xscreensaver 
167 process is running as you.  If it's not, it won't be reading the 
168 right \fI.xscreensaver\fP file.
169 .TP 8
170 .B \-watch
171 Prints a line each time the screensaver changes state: when the screen
172 blanks, locks, unblanks, or when the running hack is changed.  This option
173 never returns; it is intended for use by shell scripts that want to react to
174 the screensaver in some way.  An example of its output would be:
175 .EX
176 BLANK Fri Nov  5 01:57:22 1999
177 RUN 34
178 RUN 79
179 RUN 16
180 LOCK Fri Nov  5 01:57:22 1999
181 RUN 76
182 RUN 12
183 UNBLANK Fri Nov  5 02:05:59 1999
184 .EE
185 The above shows the screensaver activating, running three different
186 hacks, then locking (perhaps because the lock-timeout went off) then
187 unblanking (because the user became active, and typed the correct
188 password.)  The hack numbers are their index in the `programs'
189 list (starting with 1, not 0, as for the \fI\-select\fP command.)
190
191 For example, suppose you want to run a program that turns down the volume
192 on your machine when the screen blanks, and turns it back up when the screen
193 un-blanks.  You could do that by running a Perl program like the following
194 in the background.  The following program tracks the output of 
195 the \fI\-watch\fP command and reacts accordingly:
196 .EX
197 #!/usr/bin/perl
198
199 my $blanked = 0;
200 open (IN, "xscreensaver-command -watch |");
201 while (<IN>) {
202     if (m/^(BLANK|LOCK)/) {
203         if (!$blanked) {
204             system "sound-off";
205             $blanked = 1;
206         }
207     } elsif (m/^UNBLANK/) {
208         system "sound-on";
209         $blanked = 0;
210     }
211 }
212 .EE
213 Note that LOCK might come either with or without a preceeding BLANK
214 (depending on whether the lock-timeout is non-zero), so the above program
215 keeps track of both of them.
216 .SH STOPPING GRAPHICS
217 If xscreensaver is running, but you want it to stop running screen hacks
218 (e.g., if you are logged in remotely, and you want the console to remain
219 locked but just be black, with no graphics processes running) you can 
220 accomplish that by simply powering down the monitor remotely.  In a
221 minute or so, xscreensaver will notice that the monitor is off, and
222 will stop running screen hacks.  You can power off the monitor like so:
223 .EX
224 xset dpms force off
225 .EE
226 See the
227 .BR xset (1)
228 manual for more info.
229
230 You can also use
231 .BR xscreensaver-demo (1)
232 to make the monitor power down after a few hours, meaning that xscreensaver
233 will run graphics until it has been idle for the length of time you
234 specified; and after that, the monitor will power off, and screen hacks
235 will stop being run.
236 .SH DIAGNOSTICS
237 If an error occurs while communicating with the \fIxscreensaver\fP daemon, or
238 if the daemon reports an error, a diagnostic message will be printed to
239 stderr, and \fIxscreensaver-command\fP will exit with a non-zero value.  If
240 the command is accepted, an indication of this will be printed to stdout, and
241 the exit value will be zero.
242 .SH ENVIRONMENT
243 .PP
244 .TP 8
245 .B DISPLAY
246 to get the host and display number of the screen whose saver is
247 to be manipulated.
248 .TP 8
249 .B PATH
250 to find the executable to restart (for the \fI\-restart\fP command).  
251 Note that this variable is consulted in the environment of 
252 the \fIxscreensaver\fP process, not the \fIxscreensaver-command\fP process.
253 .SH UPGRADES
254 The latest version of
255 .BR xscreensaver (1)
256 and related tools can always be found at http://www.jwz.org/xscreensaver/
257 .SH "SEE ALSO"
258 .BR X (1),
259 .BR xscreensaver (1),
260 .BR xscreensaver\-demo (1),
261 .BR xset (1)
262 .SH COPYRIGHT
263 Copyright \(co 1992, 1993, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
264 by Jamie Zawinski.  Permission to use, copy, modify, distribute, and sell
265 this software and its documentation for any purpose is hereby granted without
266 fee, provided that the above copyright notice appear in all copies and that
267 both that copyright notice and this permission notice appear in supporting
268 documentation.  No representations are made about the suitability of this
269 software for any purpose.  It is provided "as is" without express or implied
270 warranty.
271 .SH AUTHOR
272 Jamie Zawinski <jwz@jwz.org>, 13-aug-92.
273
274 Please let me know if you find any bugs or make any improvements.