1 .\" $NetBSD: usbhidaction.1,v 1.14 2004/10/20 23:52:04 wiz Exp $
3 .\" Copyright (c) 2000 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Lennart Augustsson (lennart@augustsson.net).
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd perform actions according to USB HID controls
47 can be used to execute commands when certain values appear on HID controls.
48 The normal operation for this program is to read the configuration file
49 and then become a daemon and execute commands as the HID items specify.
50 If a read from the HID device fails the program dies; this will make it
51 die when the USB device is unplugged.
53 The options are as follows:
55 .It Fl c Ar config-file
56 Specify a path name for the config file.
57 When running as a daemon this needs to be an absolute path for the HUP
60 Toggle the daemon flag.
62 Ignore HID items in the config file that do not exist in the device.
64 Specify a path name for the device to operate on.
67 is numeric, it is taken to be the USB HID device number.
69 path, it is taken to be the name of the device under
71 An absolute path is taken to be the literal device pathname.
73 Specify a path name for the HID usage table file.
75 Be verbose, and do not become a daemon.
78 The config file will be re-read if the process gets a HUP signal.
80 The configuration file has a very simple format.
81 Each line describes an
82 action; if a line begins with a whitespace it is considered a continuation
84 Lines beginning with `#' are considered as comments.
86 Each line has three parts: a name of a USB HID item, a value for that item,
88 There must be whitespace between the parts.
90 The item names are similar to those used by
92 but each part must be prefixed by its page name
97 to see the page name).
98 Replace spaces in the item name by underscores.
100 The value is simply a numeric value.
101 When the item reports this value
102 the action will be performed.
103 If the value is `*' it will match any value.
105 The action is a normal command that is executed with
107 Before it is executed some substitution will occur:
108 `$n' will be replaced by the nth argument on the
109 command line, `$V' will be replaced by the numeric value
110 of the HID item, `$N' will be replaced by the name
111 of the control, and `$H' will be replaced by the name
114 .Pa /usr/share/misc/usb_hid_usages
117 The following configuration file can be used to control a pair
118 of Philips USB speakers with the HID controls on the speakers.
119 .Bd -literal -offset indent
120 # Configuration for various Philips USB speakers
121 Consumer:Consumer_Control.Consumer:Volume_Up 1
122 mixerctl -f $1 -n -w outputs.master++
123 Consumer:Consumer_Control.Consumer:Volume_Down 1
124 mixerctl -f $1 -n -w outputs.master--
125 Consumer:Consumer_Control.Consumer:Mute 1
126 mixerctl -f $1 -n -w outputs.mute++
127 Consumer:Consumer_Control.Consumer:Channel_Top.Microsoft:Base_Up 1
128 mixerctl -f $1 -n -w outputs.bass++
129 Consumer:Consumer_Control.Consumer:Channel_Top.Microsoft:Base_Down 1
130 mixerctl -f $1 -n -w outputs.bass--
133 A sample invocation using this configuration would be
134 .Bd -literal -offset indent
135 usbhidaction -f /dev/uhid1 -c conf /dev/mixer1
138 This configuration file can be used for various keyboards with extra keys:
139 .Bd -literal -offset indent
140 # Configuration for extra keyboard keys
141 Consumer:Consumer_Control.Consumer:Volume_Up 1
142 mixerctl -n -w outputs.master++
143 Consumer:Consumer_Control.Consumer:Volume_Down 1
144 mixerctl -n -w outputs.master--
145 Consumer:Consumer_Control.Consumer:Mute 1
146 mixerctl -n -w outputs.mute++
147 Consumer:Consumer_Control.Consumer:Pause/Play 1
149 Consumer:Consumer_Control.Consumer:Stop 1
151 Consumer:Consumer_Control.Consumer:Scan_Previous_Track 1
153 Consumer:Consumer_Control.Consumer:Scan_Next_Track 1
157 And this configuration can be used with, e.g.,
158 .Bd -literal -offset indent
159 usbhidaction -f /dev/uhid0 -c conf -i
169 command first appeared in