1.\" $NetBSD: usbhidaction.1,v 1.2 2000/12/30 16:18:13 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.Sh CONFIGURATION 78The configuration file has a very simple format. Each line describes an 79action; if a line begins with a whitespace it is considered a continuation 80of the previous line. Lines beginning with `#' are considered as comments. 81.Pp 82Each line has three parts: a name of a USB HID item, a value for that item, 83and an action. There must be whitespace between the parts. 84.Pp 85The item names are similar to those used by 86.Xr usbhidctl 1 , 87but each part must be prefixed by its page name. 88.Pp 89The value is simply a numeric value. When the item reports this value 90the action will be performed. 91If the value is `*' it will match any value. 92.Pp 93The action is a normal command that is executed with 94.Xr system 3 . 95Before it is executed some substitution will occur: 96`$n' will be replaced by the nth argument on the 97command line, `$V' will be replaced by the numeric value 98of the HID item, `$N' will be replaced by the name 99of the control, and `$H' will be replaced by the name 100of the HID device. 101.Sh EXAMPLES 102The following configuration file can be used to control a pair 103of Philips USB speakers with the HID controls on the speakers. 104.Bd -literal -offset indent 105# Configuration for various Philips USB speakers 106Consumer:Consumer_Control.Consumer:Volume_Up 1 107 mixerctl -f $1 -n -w fea8-i7-master++ 108Consumer:Consumer_Control.Consumer:Volume_Down 1 109 mixerctl -f $1 -n -w fea8-i7-master-- 110Consumer:Consumer_Control.Consumer:Mute 1 111 mixerctl -f $1 -n -w fea8-i7-mute++ 112Consumer:Consumer_Control.Consumer:Channel_Top.Microsoft:Base_Up 1 113 mixerctl -f $1 -n -w fea8-i7-bass++ 114Consumer:Consumer_Control.Consumer:Channel_Top.Microsoft:Base_Down 1 115 mixerctl -f $1 -n -w fea8-i7-bass-- 116.Ed 117.Pp 118A sample invokation using this configuration would be 119.Bd -literal -offset indent 120usbhidaction -f /dev/uhid1 -c conf /dev/mixer1 121.Ed 122.Sh FILES 123.Pa /usr/share/misc/usb_hid_usages 124The HID usage table. 125.Sh SEE ALSO 126.Xr usbhidctl 1 , 127.Xr usb 3 , 128.Xr uhid 4 , 129.Xr usb 4 130.Sh HISTORY 131The 132.Nm 133command first appeared in 134.Nx 1.6 . 135