Annotation of src/usr.bin/usbhidaction/usbhidaction.1, Revision 1.15
1.15 ! jmc 1: .\" $OpenBSD: usbhidaction.1,v 1.14 2020/04/20 20:54:31 ratchov Exp $
1.1 nate 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: .\"
1.15 ! jmc 31: .Dd $Mdocdate: April 20 2020 $
1.1 nate 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
1.5 jmc 39: .Op Fl div
1.1 nate 40: .Fl c Ar config-file
41: .Fl f Ar device
42: .Ar arg ...
43: .Sh DESCRIPTION
44: .Nm
45: can be used to execute commands when certain values appear on HID controls.
46: The normal operation for this program is to read the configuration file
47: and then become a daemon and execute commands as the HID items specify.
48: If a read from the HID device fails the program dies; this will make it
49: die when the USB device is unplugged.
50: .Pp
51: The options are as follows:
52: .Bl -tag -width Ds
53: .It Fl c Ar config-file
54: Specify a path name for the config file.
55: .It Fl d
56: Toggle the daemon flag.
57: .It Fl f Ar device
1.4 jmc 58: Specify a path name for the device to operate on.
59: If
1.1 nate 60: .Ar device
1.4 jmc 61: is numeric, it is taken to be the USB HID device number.
62: If it is a relative path, it is taken to be the name of the device under
1.1 nate 63: .Pa /dev .
64: An absolute path is taken to be the literal device pathname.
1.5 jmc 65: .It Fl i
66: Ignore HID items in the config file that do not exist in the device.
1.1 nate 67: .It Fl v
68: Be verbose, and do not become a daemon.
69: .El
70: .Pp
1.13 anton 71: The config file will be re-read upon receiving
72: .Dv SIGHUP .
1.1 nate 73: .Sh CONFIGURATION
1.4 jmc 74: The configuration file has a very simple format.
75: Each line describes an action; if a line begins with a whitespace
76: it is considered a continuation of the previous line.
77: Lines beginning with `#' are considered as comments.
1.1 nate 78: .Pp
79: Each line has three parts: a name of a USB HID item, a value for that item,
1.4 jmc 80: and an action.
81: There must be whitespace between the parts.
1.1 nate 82: .Pp
83: The item names are similar to those used by
84: .Xr usbhidctl 1 ,
85: but each part must be prefixed by its page name.
86: .Pp
1.4 jmc 87: The value is simply a numeric value.
88: When the item reports this value the action will be performed.
1.1 nate 89: If the value is `*' it will match any value.
90: .Pp
1.11 jasper 91: The action is a normal command that is executed by using
92: .Xr fork 2 .
1.1 nate 93: Before it is executed some substitution will occur:
94: `$n' will be replaced by the nth argument on the
95: command line, `$V' will be replaced by the numeric value
96: of the HID item, `$N' will be replaced by the name
97: of the control, and `$H' will be replaced by the name
98: of the HID device.
99: .Sh FILES
100: .Pa /usr/share/misc/usb_hid_usages
101: The HID usage table.
102: .Sh EXAMPLES
1.10 jakemsr 103: The following configuration file can be used to control the
104: master volume and muting of an
105: .Xr azalia 4
106: device using the multimedia keys on a Belkin USB keyboard.
1.1 nate 107: .Bd -literal -offset indent
1.15 ! jmc 108: # The volume range is 0..1. Moving 0.05 volume steps, each keypress
1.10 jakemsr 109: # moves quickly through the volume range but still has decent
110: # granularity.
1.12 bentley 111: Consumer:Volume_Increment 1
1.15 ! jmc 112: sndioctl -f $1 output.level=+0.05
1.12 bentley 113: Consumer:Volume_Decrement 1
1.15 ! jmc 114: sndioctl -f $1 output.level=-0.05
1.10 jakemsr 115: Consumer:Mute 1
1.15 ! jmc 116: sndioctl -f $1 output.mute=!
1.1 nate 117: .Ed
118: .Pp
119: A sample invocation using this configuration would be
120: .Bd -literal -offset indent
1.15 ! jmc 121: $ usbhidaction -f /dev/uhid1 -c conf snd/0
1.1 nate 122: .Ed
123: .Sh SEE ALSO
124: .Xr usbhidctl 1 ,
125: .Xr usbhid 3 ,
126: .Xr uhid 4 ,
127: .Xr usb 4
128: .Sh HISTORY
129: The
130: .Nm
131: command first appeared in
132: .Ox 3.2 .