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