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