No project description provided
Project description
Map2
A python library that allows complex key remapping on Linux, written in Rust.
Warning: this is the experimental python branch, the API is likely to change, please don't be annoyed or wait until it's on master.
All of the functionality related to interacting with graphical elements such as getting the active window information is currently only supported on X11. Wayland support is planned but probably won't be added for some time.
For details check the documentation.
Important note:
The legacy version of map2 which used a custom scripting langauge is located
here.
Due to performance and growing requirements map2 now uses python for the user
scripts. Map2 itself is still written in rust and compiled for maximum
performance.
Examples
Map2 supports use cases ranging all the way from simple key remappings to using complex callbacks and variables.
import map2
# a reader intercepts all input from device file descriptiors
reader = map2.Reader(patterns=[
"/dev/input/by-id/usb-Logitech_USB_Receiver-if01-event-.*",
"/dev/input/by-id/usb-Logitech_G700s_Rechargeable_Gaming_Mouse_017DF9570007-.*-event-.*",
"/dev/input/by-path/pci-0000:03:00.0-usb-0:9:1.0-event-kbd",
])
# a writer is responsible for remapping and outputting the modified input event stream
# it attaches to a reader, meaning the event stream is piped through
writer = map2.Writer(reader)
# change the 'a' key to 'b'
writer.map_key("a", "b")
def hello_world():
print("hello world")
# type the text using the virtual keyboard
writer.send("some text{enter}")
# map the 'c' key to a callback function
writer.map("c", hello_world)
# a window object listens to changes in the currently active window
window = map2.Window()
# do something on window change
def on_window_change(active_window_class):
if active_window_class == "firefox"):
print("firefox is now the active window")
# map 'F1' to ctrl+'t' (open new browser tab)
writer.map_key("f1", "^t")
else:
print("firefox is not the active window")
# map 'F1' back
writer.map_key("f1", "f1")
}
# register the callback
window.on_window_change(on_window_change)
# keep running until terminated
map2.wait()
For more examples check the examples directory.
Getting started
tldr:
- find the input device file descriptors you want to grab
- write a script file for remapping the keys, pass the descriptors to a
new
reader
object, remap keys on a newwriter
object - run
$ python my_remapping_script.py
Detailed documentation is still being worked on, consult the example scripts.
Install
TODO this section
- add
etc/udev/rules.d/10-my-udev.rules
groupadd map2
# create "map2" group
KERNEL=="event*", SUBSYSTEM=="input", ATTRS{hid}=="MYDEV000", MODE="0644", GROUP="map2", SYMLINK+="input/mydevice"
# add yourself to the "map2" group
$ usermod -aG `whoami` map2
Arch Linux
Arch packages are not available yet for the python branch.
Other distributions
Build local package from cloned source:
- download the source code from this repository
- install maturin and rust
- build using
$ maturin build --release
- install using
$ pip install target/wheels/NAME_OF_WHEEL_FILE.whl
Documentation
Detailed documentation is still being worked on, consult the example scripts.
Feature roadmap
- finalize python branch
- documentation (async callbacks, public API, etc.)
- deploy python branch to package repos
- fd patterns file
- add tests
- AHK-style hotstrings
- escaped characters in strings and key sequences
- pre-packaged binaries for various distros
- mouse events
- Wayland support (someday)
Contributing
If you want to report bugs, add suggestions or help out with development please check the issues page and open an issue if it doesn't exist yet.
License
MIT
Authors
- shiro shiro@usagi.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for map2-2.0.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14d125ac2d729b95d64224ef591a89ea355b4e674f5cfcce62411e6311ba7f93 |
|
MD5 | e0c4875abe79caa398e07618050b783b |
|
BLAKE2b-256 | 462d2ffe7f24f3e2a977bdc74f3767c0f04a9ef54416d00880ffcc11e5ded04d |
Hashes for map2-2.0.2-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ac3a603fcdf24ba4945c8ad6e71743c8d3895df4689f2856c49eb36997d809 |
|
MD5 | 8e9f1decbbe4344a26e2f317fdc0879f |
|
BLAKE2b-256 | 177c8dd88b38a47a7259d8d269eafd4705aa13b8b9a313e8b1172c388374452f |
Hashes for map2-2.0.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c120138428ddffae9f755f36646bf4aae5fe7f4a6ea60de56800c98ebda6de02 |
|
MD5 | 7bcbbfb69cf01747aeb04c7f9815a8fe |
|
BLAKE2b-256 | 2881576e5bb4a032f1ef53ca2ad528736bafcfbfaaa6e3adaec11f9a62296c09 |
Hashes for map2-2.0.2-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 674e41b05068de220af0ef47a2888be88cb5a9635f117bdfd481cf88d7737e20 |
|
MD5 | 2db6e402b932d65e1e4a5237af9db318 |
|
BLAKE2b-256 | 2fd9b94760a6eaa8fede2a5dd025f4ee6702b62a9a811aa47bed47b5bf9093b5 |
Hashes for map2-2.0.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 786eec35f2fbdcf740ac723414e0de262fd90c4577a8a8ea87911b58c4a6bb91 |
|
MD5 | 709ee05ffaba87eea74e6e4919d6d810 |
|
BLAKE2b-256 | 6fedd8a758758ee586c0353f9c2b22829555f52b52d125782ecd5011675a62c7 |
Hashes for map2-2.0.2-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b17462129c5e239064c04f08a961d2633e2d8895654e1736106bffdaa5d2157 |
|
MD5 | 2d4870a45f06e82e313b5bb1b2b40a67 |
|
BLAKE2b-256 | cb7a24b1a42855582c75b5511225f281a5f86fd5ec5ad459fad12b3ec9261772 |
Hashes for map2-2.0.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78cc4a07114ae5ddc8eea3ad6b99775dffaa68c76f121b73f8f33f42a33c098f |
|
MD5 | 3f85d801d2796eb209b62286ba2b44c2 |
|
BLAKE2b-256 | 9f9e76240d5ee9c60994f30d3bf19859e5f064e5d003ddc9d4bc0bbba50fba7d |
Hashes for map2-2.0.2-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc14d60790eac01bcb368a95d2538b4b0e15db5df857fa82ae5b191dd0841089 |
|
MD5 | 1d95d6d1747ee38aefd342d92f319ed5 |
|
BLAKE2b-256 | d9cb491744c8ddb6f54f88609f89500e3f2b41c180ce842efdec13028cad1035 |
Hashes for map2-2.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d436651593afe5e487e3a548bbaa801f846423d2bee51c5a0019feedd822f71b |
|
MD5 | 80788d989353eb53c962e54621ac3af6 |
|
BLAKE2b-256 | ae138e239949bf2aa78a7267392a6d0e2840411494ad223b7ef3839b2d8643b4 |
Hashes for map2-2.0.2-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 836d8e2784e25ba96971db7087d619845e22727fa157b54a44ae41df97aca22a |
|
MD5 | 2eec0799823bcd6d7d965bb326831ef1 |
|
BLAKE2b-256 | d28fb0bd679ce10cf2240e72d0c74884233c990c299051609c54b99024a68095 |
Hashes for map2-2.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05e701ebb3ebaaa170a7790e56c38ac1f8f4e4581413c7a6a2557db7c4d56046 |
|
MD5 | 5dff64cb78c63d5f06a484f93df9b18c |
|
BLAKE2b-256 | e840964e73f0f034af7952f47c07f95643cbad990600739aade6a51913c32001 |
Hashes for map2-2.0.2-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74450e31b4bb34a01bb65d832bf2fb797ee339eeb187ea1e8d42207b949b0fc |
|
MD5 | 8b1925a59a996f351fec7b05db03c844 |
|
BLAKE2b-256 | ab404001987028dc549e19eb3b798c03158f2c87c9fccbb23ea262936bbc7999 |
Hashes for map2-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d1b0467750fbae30363dec6686b2f4e9a38c0b4411c71c70ca4771f2acb1d27 |
|
MD5 | 18b8f4ebd832e7a3f85fd7caf3f3abc3 |
|
BLAKE2b-256 | c71782bb1a5e2c2d61a0bc145c42b785f03b9e5b12a53555652e923274013d3e |
Hashes for map2-2.0.2-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1aff523db2ae5a8f67bae7005dc5ac4fcf393f8447bf847f43f68714e0dade1 |
|
MD5 | 6dab99c98e23b0928540d5df0dbf76e6 |
|
BLAKE2b-256 | b90625583f9d798af766aab1a6041226f2416dd4e9876599bb0e5ace3bb39bd5 |
Hashes for map2-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95f58af6111def9f15f0c6e185596934aba480837958c17cc80deaea120b8d64 |
|
MD5 | 4976e420afeaf422a90e5238f06c3f15 |
|
BLAKE2b-256 | e41a6926c3eb02d894099f151e10b739219e5ddb8cf92be7036028e3943d237c |
Hashes for map2-2.0.2-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2f7817ce52feeefd733adafe8c40546860b840deaaef0f83c354557e0763230 |
|
MD5 | 65cff1d7b8d50858a3ee7e18feb2c72a |
|
BLAKE2b-256 | e0a4fb0adf7db31327273fdece501c2587a23d39c1a52cecc32ddba19a92b6e9 |
Hashes for map2-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0df2b53e782806a93200cda02e99312db533564f9ce0d38f9ef112eb28ba8c95 |
|
MD5 | e3dfeb29e49779348cd13708a6694b8f |
|
BLAKE2b-256 | ecec2eed0a7d85da71e49e622a56301b5a7a1f8a4448b693c1c2719e7fe9c951 |
Hashes for map2-2.0.2-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a25d7e6a774f79be19001fafcea7dc73298e5d12e0233d72941430f2920a1f3d |
|
MD5 | 2b79311e9dc9b60e2785d6cd59226b2c |
|
BLAKE2b-256 | 60f73514b798e4a3cc02163679ecb19c8b5fd7cb7dda6eb64842ceb6e5eefc81 |
Hashes for map2-2.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b2bacf269e50167601ac1aa379dd1edf28dcb70d8db72f0750bfbe49ae5f9fb |
|
MD5 | cf502fb15fe5b9d93607868363e189df |
|
BLAKE2b-256 | 281f5c5c1710adaa49e0f24faff5fb52b419f6360d36d7937a3bba54087ed036 |
Hashes for map2-2.0.2-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cef7110efb42acf72d2082a68e5291db1ea0b095d23e79b97a19e6d143fd7c8 |
|
MD5 | 546ee0467b146d687a3072906f0fc2df |
|
BLAKE2b-256 | 6a928a47f1a2718dee2440123038b9dd9717f4e74a85b8923cbd77cba1e5afed |