File: thd.pod

package info (click to toggle)
triggerhappy 0.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 264 kB
  • sloc: ansic: 1,449; sh: 81; makefile: 53
file content (168 lines) | stat: -rw-r--r-- 6,781 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
=pod

=head1 NAME

thd -- triggerhappy global hotkey daemon

=head1 SYNOPSIS

B<thd> [B<--help>] [B<--user> I<name>] [B<--listevents>] [B<--dump>] [B<--socket> I<socket>] [B<--triggers> I<config>] [B<--daemon>] [B<--pidfile> I<file>] [B<--uinput> I<device>][B<--ignore> I<event>] [B<--deviceglob> I<pattern>] [I<devices...>]

=head1 DESCRIPTION

Triggerhappy is a hotkey daemon that operates on a system wide scale. It watches all configured input devices
for key, switch or button events and can launch arbitrary commands specified by the administrator. In contrast
to hotkey services provided by desktop environments, Triggerhappy is especially suited to hardware related switches
like volume or wifi control; it works independently from a specific user being logged in and is also suitable for embedded systems that do not a graphical user interface.

=head1 OPTIONS

=over

=item B<--help>

Shows usage instructions

=item B<--listevents>

Prints a list of all known event names.

=item B<--triggers> F<conf>

Read trigger definitions from F<conf>, which can either be a file or a directory. If a directory is specified, all its files matching the pattern *.conf are loaded.

=item B<--dump>

Dump all recognized events to STDOUT. This can also be utilized to create a skeleton trigger configuration by redirecting the printed configuration lines to a configuration file, adding the desired command and activating the generated line by removing the comment mark "#" at its beginning:

  thd --dump /dev/input/event* | grep ^# > /etc/triggerhappy/triggers.d/skeleton.conf

=item B<--socket> F<file>

Open a unix domain socket at F<file>; this socket can be used to send commands to the running daemon (by using the program L<th-cmd>), e.g. for adding or removing devices.

=item B<--daemon>

Run as a background daemon and detach from the terminal.

=item B<--pidfile> F<file>

Write PID to F<file>.

=item B<--uinput> F<device>

Open uinput file (probably F</dev/input/uinput>) to generate synthetic events.

=item B<--ignore> I<eventname>

Ignore key and switch event labeled I<eventname>. This can be used to suppress the FN key on some notebooks which only generates events sometimes and might screw up key combinations.

=item B<--normalize>

Normalize REL and ABS events. If this option is enabled, the values of axis movement events are mapped to the three values -1, 0 and 1, depending on the sign of the value reported by the kernel.

=item B<--user> I<name>

Change to user id I<name> after opening files. This usually prevents thd from opening additional input devices, unless they are opened by the th-cmd program and their file descriptor are passed to the daemon.

=item B<--deviceglob> I<pattern>

Open device files matching the glob I<pattern>.

=back

Additional command line arguments are considered filenames of input devices.

=head1 CONFIGURATION


=head2 Configuring event handlers

The hotkey bindings used by Triggerhappy are set in the configuration file specified by B<--triggers>. Each line consists of three segments:
The symbolic name of the key or event name to react on, the value carried by the expected event, and of course the command to be launched.

The event names can be identified by operating the desired key or switch while running the triggerhappy daemon with the option B<--dump>.

Key events carry the value I<1> for a key being pressed and transmit the payload I<0> when it is released; holding the key down constantly yields events with a value of I<2>.

The command can include any number of arguments. Please include the full path to avoid trouble through different $PATH settings for the daemon and your interactive session.

The three fields are separated by an arbitrary number of whitespaces, while anything behind a # character is ignored and considered a comment.

=head1 EXAMPLE

=head2 Starting the daemon

B<thd --dump /dev/input/event*>

Dump all events processable by thd to the console; this is useful to find out the correct event name for a specific key.

B<thd --triggers /etc/triggerhappy/triggers.d/ /dev/input/event*>

Read from all currently connected input devices and process events according to the files in F</etc/triggerhappy/triggers.d/>.

B<thd --triggers /etc/triggerhappy/triggers.conf --socket /var/run/thd.socket>

Do not open any input devices yet, but bind the socket F</var/run/thd.socket> for L<th-cmd> to connect to.

=head2 Configuration files

Any number of event handlers can be placed in the configuration file:

    # /etc/triggerhappy/triggers.d/suspend.conf
    #
    # Suspend the system
    KEY_SLEEP                   1       /usr/sbin/hibernate-ram
    KEY_SLEEP+KEY_LEFTSHIFT     1       /usr/sbin/hibernate-disk

    # /etc/triggerhappy/triggers.d/audio.conf
    # Change mixer volume when pressing the appropriate keys (or holding them)
    KEY_VOLUMEUP    1      /usr/bin/amixer set Master 5%+
    KEY_VOLUMEUP    2      /usr/bin/amixer set Master 5%+
    KEY_VOLUMEDOWN  1      /usr/bin/amixer set Master 5%-
    KEY_VOLUMEDOWN  2      /usr/bin/amixer set Master 5%-

In more complex situations, triggerhappy can provide multiple modes that map a
single event to different keys; triggers are bound to a specific mode by appending
its name to the event name:

    KEY_KPPLUS@media	1	/usr/bin/mpc next
    KEY_KPMINUS@media	1	/usr/bin/mpc prev

These two lines will only cause mpc to be called if the triggerhappy daemon is in
"media" mode. Changing the mode can be achieved by placing a special trigger inside
the configuration:

    KEY_F12@		1	@media
    KEY_F12@media	1	@

These two lines make the F12 key toggle between the (nameless) default mode and the
newly defined media mode.

Triggers with "@" appended are only executed if the specified mode is active; all other
triggers are enabled in every mode.

When launched with the option B<--uinput>, triggerhappy can be used to generate
synthetic events. A virtual input device is created which emits specified key
presses once a special trigger is reached:

    KEY_KPASTERISK	1	<KEY_VOLUMEDOWN

By prepending a keycode with the special character '<', other applications will
receive a press and release of the corresponding key. This is especially useful
to remap or mirror events generated by devices exclusively serviced by the
triggerhappy daemon.

It is possible to create handlers that only react to specific devices: to achieve
such behaviour, add the input device using B<th-cmd> and supply it with a tag; this
tag can then be used to limit the scope of a trigger to this device:

    <remote>KEY_ENTER	1	/usr/bin/mpc stop

Defining the hotkey in this way will only trigger the handler if the event is received
from a device tagged "remote".

=head1 AUTHOR

Stefan Tomanek E<lt>stefan.tomanek+th@wertarbyte.deE<gt>