A common problem is that users will have devices which split their functionality
between several device nodes (e.g laptop keyboards). It is often desirable to
only remap a subset of these device nodes so that some of them can operate
unintercepted by keyd (e.g touchpads) or be assigned to a different config.
This patch moves away from vendor/product id pairs by introducing unique identifiers.
To maintain backward compatibility, prefix matching is used and the old identifiers
are valid substrings of the new ones.
As a byproduct of this, a new bug/feature is born. <vendor id> in
isolation will now also match any device with the given vendor id.
Woe betide the user that makes use of this.
Add support for Gnome 45, which breaks backward extension
compatibility. We now ship and maintain two extensions :/.
The main change in Gnome seems to be the switch from a custom
import implementation to 'standard' ES6 style imports.
The init method also seems to have inexplicably
been swapped out in favour of extending a magic
class.
This patch takes the opportunity to clean up some residual cruft
and move the extension code out of the mapper script.
Specifically:
- Ship distinct extensions for Gnome 42-44 and Gnome 45 in /usr/local/share/keyd
- Move the named pipe to XDG_RUNTIME_DIR
- Initialize the pipe inside the extension instead of the script
to avoid potential race conditions during initialization.
Some distros set this flag by default, so it
seems prudent to ensure we can compile with it
set. This should fix master compilation
issues on arch and fedora.
It turns out the linux uinput driver is capable of
automatically generating repeat events if you
flip the right kernel bit, so we can eliminate
the kludgy thread based repeat logic.
This should also fix#397, since said code was relying
on undefined pthread behaviour that caused some systems
to busy wait.
Simplify the modifier table and reuse config parsing logic to simplify
config initialization. This comes with a small performance
penalty when parsing configs (~50 us), but makes things much
tidier.
For the moment these are functionally equivalent the end-to-end python tests
(make test) without spinning up and exercising the daemon. Eventually they
should extend or complement them.
Mostly plumbing.
Summary:
- Key processing logic remains untouched.
- Simplified IPC logic.
- Streamlined the event loop.
- Consolidated config and descriptor parsing logic into config.[ch].
- Eliminated internal KEYD_* environment variables in favour of compile time macros.
- Added color coding to the daemon output.
- Load all configuration files on initialization.
The last change increases initialization time (on the order of μs) and resident
memory size, but simplifies the config logic and has the benefit of linting all
files immediately while also allowing for the introduction of in-daemon
reloading. This ultimately results in a net saving for the user since
most service managers are horrendously slow :(.
It also means hotplugged devices will use the in-memory config set (which
probably makes more sense anyway) instead of dynamically scanning the config
directory. This is more efficient for small config directories (<100 files),
but less efficient for large ones (uncommon).
- usleep was removed in POSIX.1-2008 (X/Open Issue 7)
- DT_DIR and flock are BSD extensions but BSDs don't use _DEFAULT_SOURCE
- _DEFAULT_SOURCE in GNU exposes POSIX.1-2008 + BSD + SysV mix
Tidy up the parsing logic and make everything valid c11
while we are at it :P.
The patch also eliminates the optional macro argument from swap(),
replacing it with a dedicated function (swap2()).
This breaks compatibility with a small number of configs,
but makes things more consistent.
The stock XCompose file which ships with most distros isn't exhaustive
and uses a number of layout specific keysyms intended to be easy to
memorize (rather than globally accessible). To circumvent this problem
we ship our own set of simplified compose definitions.
If we encounter a utf8 sequence corresponding to a glyph for which a
known XKB compose sequence exists, we replace the glyph with the
corresponding sequence. This allows non-english users to easilly specify
alternate glyphs without having to memorize the appropriate macros.
This is a major release which breaks backward compatibility for
non-trivial configs. (we are still in beta after all :P).
In the absence of too much blowback this will probably become the final
v2 design.
Much of this harkens back to the v1, with some additional simplifications
and enhancements.
See DESIGN.md for a more detailed account.
The end result should (hopefully) be a little more robust (and systemd independent).
I no longer remember what possessed me to switch away from the original
inotify implementation, but udev detection seems to have caused
enough grief to warrant switching back.
This will probably break FreeBSD support without some kind of
inotify glue and/or a kqueue implementation. If any FreeBSD
users see this feel free to open an issue or submit a PR :P.