1.\" $NetBSD: usbhidaction.1,v 1.6 2002/01/18 14:38:59 augustss Exp $
2.\"
3.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Lennart Augustsson (lennart@augustsson.net).
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd December 29, 2000
38.Dt USBHIDACTION 1
39.Os
40.Sh NAME
41.Nm usbhidaction
42.Nd perform actions according to USB HID controls
43.Sh SYNOPSIS
44.Nm ""
45.Fl c Ar config-file
46.Op Fl d
47.Op Fl i
48.Fl f Ar device
49.Op Fl v
50.Ar arg ...
51.Sh DESCRIPTION
52.Nm
53can be used to execute commands when certain values appear on HID controls.
54The normal operation for this program is to read the configuration file
55and then become a daemon and execute commands as the HID items specify.
56If a read from the HID device fails the program dies; this will make it
57die when the USB device is unplugged.
58.Pp
59The options are as follows:
60.Bl -tag -width Ds
61.It Fl c Ar config-file
62Specify a path name for the config file.
63.It Fl d
64Toggle the daemon flag.
65.It Fl i
66Ignore HID items in the config file that does not exist in the device.
67.It Fl f Ar device
68Specify a path name for the device to operate on.  If
69.Ar device
70is numeric, it is taken to be the USB HID device number.  If it is a relative
71path, it is taken to be the name of the device under
72.Pa /dev .
73An absolute path is taken to be the literal device pathname.
74.It Fl v
75Be verbose, and do not become a daemon.
76.El
77.Pp
78The config file will be re-read if the process gets a HUP signal.
79.Sh CONFIGURATION
80The configuration file has a very simple format.  Each line describes an
81action; if a line begins with a whitespace it is considered a continuation
82of the previous line.  Lines beginning with `#' are considered as comments.
83.Pp
84Each line has three parts: a name of a USB HID item, a value for that item,
85and an action.  There must be whitespace between the parts.
86.Pp
87The item names are similar to those used by
88.Xr usbhidctl 1 ,
89but each part must be prefixed by its page name.
90.Pp
91The value is simply a numeric value.  When the item reports this value
92the action will be performed.
93If the value is `*' it will match any value.
94.Pp
95The action is a normal command that is executed with
96.Xr system 3 .
97Before it is executed some substitution will occur:
98`$n' will be replaced by the nth argument on the
99command line, `$V' will be replaced by the numeric value
100of the HID item, `$N' will be replaced by the name
101of the control, and `$H' will be replaced by the name
102of the HID device.
103.Sh FILES
104.Pa /usr/share/misc/usb_hid_usages
105The HID usage table.
106.Sh EXAMPLES
107The following configuration file can be used to control a pair
108of Philips USB speakers with the HID controls on the speakers.
109.Bd -literal -offset indent
110# Configuration for various Philips USB speakers
111Consumer:Consumer_Control.Consumer:Volume_Up			   1
112	mixerctl -f $1 -n -w fea8-i7-master++
113Consumer:Consumer_Control.Consumer:Volume_Down			   1
114	mixerctl -f $1 -n -w fea8-i7-master--
115Consumer:Consumer_Control.Consumer:Mute				   1
116	mixerctl -f $1 -n -w fea8-i7-mute++
117Consumer:Consumer_Control.Consumer:Channel_Top.Microsoft:Base_Up   1
118	mixerctl -f $1 -n -w fea8-i7-bass++
119Consumer:Consumer_Control.Consumer:Channel_Top.Microsoft:Base_Down 1
120	mixerctl -f $1 -n -w fea8-i7-bass--
121.Ed
122.Pp
123A sample invocation using this configuration would be
124.Bd -literal -offset indent
125usbhidaction -f /dev/uhid1 -c conf /dev/mixer1
126.Ed
127.Sh SEE ALSO
128.Xr usbhidctl 1 ,
129.Xr usbhid 3 ,
130.Xr uhid 4 ,
131.Xr usb 4
132.Sh HISTORY
133The
134.Nm
135command first appeared in
136.Nx 1.6 .
137