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