3 * woof.d - Bark whenever new processes appear. Needs /dev/audio.
4 * Written in DTrace (Solaris 10 3/05).
6 * $Id: woof.d 3 2007-08-01 10:50:08Z brendan $
10 * SEE ALSO: /usr/dt/bin/sdtaudiocontrol # to set volume
12 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
16 * The contents of this file are subject to the terms of the
17 * Common Development and Distribution License, Version 1.0 only
18 * (the "License"). You may not use this file except in compliance
21 * You can obtain a copy of the license at Docs/cddl1.txt
22 * or http://www.opensolaris.org/os/licensing.
23 * See the License for the specific language governing permissions
24 * and limitations under the License.
28 * 14-Aug-2006 Brendan Gregg Created this.
29 * 14-Aug-2006 " " Last update.
32 #pragma D option quiet
33 #pragma D option destructive
34 #pragma D option switchrate=10hz
36 inline int SCREEN_OUTPUT = 0; /* Set to 1 for screen output */
38 /* barks prevents woof.d from barking too much (up to 20 barks/second) */
43 SCREEN_OUTPUT ? trace("Beware of the dog!\n") : 1;
47 * Call the shell to run a background audioplay command (cat > /dev/audio
48 * doesn't always work). One problem this creates is a feedback loop,
49 * where we bark at our own barks, or at other dogs barks; entertaining
50 * as this is, it can really slog the system and has been avoided by
51 * checking our ancestory.
54 /!progenyof($pid) && barks++ < 2/
56 SCREEN_OUTPUT ? trace("Woof! ") : 1;
57 system("audioplay /usr/share/audio/samples/au/bark.au &");