- You may have used my work:
wez / evremap Goto Github PK
View Code? Open in Web Editor NEWA keyboard input remapper for Linux/Wayland systems, written by @wez
License: MIT License
A keyboard input remapper for Linux/Wayland systems, written by @wez
License: MIT License
I was considering switching away from keyszer which is an xkeysnail fork to everemap but found issues while migrating my configuration over.
Keys which have been remapped are unable to be remapped again. I found this by trying to remap capslock to F20 and then have other remaps depend on F20 with another key.
Configurations like this would be ideal:
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_F20"]
[[remap]]
input = ["KEY_F20", "KEY_W"]
output = ["KEY_HOME"]
[[remap]]
# this "deadnaming" could work for me but would probably be unintuitive for others
input = ["KEY_CAPSLOCK", "KEY_R"]
output = ["KEY_END"]
This would effectively disable capslock while still providing it as a modifier key for other remaps.
I also tried this remap but it sends w and q separately instead of remapping them to numlock.
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_W", "KEY_Q"]
[[remap]]
input = ["KEY_W", "KEY_Q"]
output = ["KEY_NUMLOCK"]
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_LEFTSHIFT", "KEY_Q"]
[[remap]]
input = ["KEY_LEFTSHIFT", "KEY_Q"]
output = ["KEY_NUMLOCK"]
This last one only types Q (capitalized) into a notepad.
running sudo target/release/evremap remap /etc/evremap.toml
from the terminal gives output
WARN evremap > Short delay: release any keys now!
INFO evremap::remapper > Going into read loop
but has no tangible effect.
sudo systemctl start evremap.service
Gives on immediate error
but systemctl status evremap.service
reports
Active: failed
and
(code=exited, status=127)
(more detail in [[[issue]])
lenovo laptop
arch / wayland / hyperland
Systemd 255 (255.2-2-arch)
Fair warning I'm still quite new to Linux and especially arch, used pop os for awhile but that just tends to work so my troubleshooting could use some practice.
I've installed evremap to try and sort out my keybinds
I cloned it into ~/Applications
folder and built with cargo,
then made a config file and put it in the default location
#/etc/evremap.toml
device_name = "AT Translated Set 2 keyboard"
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_BACKSPACE"]
[[dual_role]]
input = "KEY_LEFTSHIFT"
hold = ["KEY_LEFTSHIFT"]
tap = ["KEY_CAPSLOCK"]
Added the default service to /usr/lib/systemd/system/
and then set it up
[Service]
WorkingDirectory=/
ExecStart=bash -c "/usr/bin/evremap remap /etc/evremap.toml -d 0"
Restart=always
[Install]
WantedBy=multi-user.target
with the following commands as recommended by the README
$ sudo cp evremap.service /usr/lib/systemd/system/
$ sudo systemctl daemon-reload
$ sudo systemctl enable evremap.service
$ sudo systemctl start evremap.service
Created an input group
echo 'KERNEL=="event*", NAME="input/%k", MODE="660", GROUP="input"' | sudo tee /etc/udev/rules.d/input.rules
added evdev
and uinput
to the group
sudo gpasswd -a YOUR_USER input
echo 'KERNEL=="uinput", GROUP="input"' | sudo tee /etc/udev/rules.d/input.rules
rebooted
This dosen't appear to have worked as systemctl status evremap.service
states "failed"
Process: 34059 ExecStart=bash -c /usr/bin/evremap remap /etc/evremap.toml -d 0 (code=exited, status=127)
full output:
× evremap.service
Loaded: loaded (/usr/lib/systemd/system/evremap.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Tue 2024-01-16 04:56:13 GMT; 3s ago
Duration: 6ms
Process: 4883 ExecStart=bash -c /usr/bin/evremap remap /etc/evremap.toml -d 0 (code=exited, status=127)
Main PID: 4883 (code=exited, status=127)
CPU: 6ms
Jan 16 04:56:13 archlinux systemd[1]: evremap.service: Scheduled restart job, restart counter is at 5.
Jan 16 04:56:13 archlinux systemd[1]: evremap.service: Start request repeated too quickly.
Jan 16 04:56:13 archlinux systemd[1]: evremap.service: Failed with result 'exit-code'.
Jan 16 04:56:13 archlinux systemd[1]: Failed to start evremap.service.
ran sudo target/release/evremap remap /etc/evremap.toml
just in case, no change.
Repeated all steps from [[setup]] again with no change.
As I understand it error code 127 indicates “command not found”
So I checked for the executable called at /usr/bin/evremap
but no directory called evremap exists in /usr/bin/
I edited /usr/lib/systemd/system/evremap.service to call the folder I built evremap in /home/joe/Applications/evremap/ and ran
$ sudo cp evremap.service /usr/lib/systemd/system/
$ sudo systemctl daemon-reload
$ sudo systemctl enable evremap.service
$ sudo systemctl start evremap.service
again. Still no change.
Tried a similar thing with the path /home/joe/Applications/evremap/target/release/ but still no success.
remap just isn't a command on any of these paths.
I tried which -a remap
but nothing relevant came up.
I'm not sure what to try next, any advice?
I cannot remap keys on my Cherry Wired Keyboard. evremap config.toml
does not ouput an error message, but does not have any effect. evremap list-devices
shows two devices named "Cherry GmbH CHERRY Wired Keyboard' with two different events. I have no clue what is the right event for the keyboard, but maybe evremap
takes the wrong one. The keyboard name seems to be ambiguous.
I have another keyboard, the Logitech K380 bluetooth keyboard, which has three devices. But these devices have three different names, "Keyboard K380 Keyboard", "Keyboard K380 System Control" and "Keyboard K380 Consumer Control", and taking the first one works.
Hey, thanks for evremap. Just wanted to let you know that it is not necessary to run evremap as root, and I think this could allow the feature of evremap to handle sending commands as well. On my system I run evremap as an unprivileged user like so:
sudo gpasswd -a YOUR_USER input
echo 'KERNEL=="uinput", GROUP="input"' | sudo tee /etc/udev/rules.d/input.rules
I would propose adding these optional steps to the README and allowing the user to define commands on keypress. For me this means not needing another program like swhkd or AutoKey to do that.
I've been looking for a lightweight input remapper. You project is absolutely amazing, it's so efficient and so easy to work with.
I created a forked version of the project. I added the ability to execute command using a hotkey. In my case, that's the command to logout from gnome session (to be used in case of GPU hang). Here's link to my forked version: https://github.com/ngxson/hobby-evremap/blob/master/src/remapper.rs#L446
However, since I don't have much knowledge about rust, I can only hard-code the command. It would be nice to have an option in the toml file.
I'm using a keyboard with a UK physical layout, but I'm using another (Swiss) layout. The physical key for 'baskslash' doesn't exist on my keyboard (as with my Swiss layout, the resuling key is mapped to the $ sign). I wanted to use evremap to regain access to the backslash symbol by mapping an unused key to it.
I tried mapping an unused key to KEY_BACKSLASH, but that actually maps the key to the $ sign. I also can't find the angle brackets (less/grater than) in the evremap list-keys command, I suspect that is because they're located on the same key as where by backslash would be, and so I can't access them. Am I right to assume I can't get what I want with evremap?
I nearly went insane because I couldn't understand where to put my config that I ran with the normal evremap remap command (no systemd). Might be possible that both .conf and .tomf work, but when I personally tried to export my text file as a .tomf it didn't work. So maybe adjust the ExecStart line in the .service file to ExecStart=bash -c "/usr/bin/evremap remap /etc/evremap.conf -d 0"
this is my current config
phys = "5c:c9:d3:7d:6d:0f"
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_FN"]
i need FN combinations for several commands such as fn + } = END
, which is how my keyb works,
but the remap as it is only removes the capslock function of the capslock key, without adding the fn funcion
have you got an idea of what could be the problem?
Hello, your code here looks right up the alley of what I'm looking for, but I've noticed some unexpected behavior as I'm trying it out, wondering if I'm just doing something wrong. Here's my config (minus the device name):
[[remap]]
input=["KEY_A", "KEY_S"]
output = ["KEY_N"]
Every time I hit the combo, I get not only an n
, but also an s
or an a
. I was expecting/hoping to just get the n
. Is this an expected behavior? If so, I might take the time to dig in and see if I can resolve that at least for my own use, and I'm happy to submit a PR for it if you would like.
It would be good to add a [[sequence]]
type of binding where rather than chords of keys (eg. KEY_LEFTCTRL
and KEY_F24
) being pressed at once, sequences of keys pressed one after the other (eg. KEY_LEFTCTRL
and then KEY_F24
) can be used as valid values for input
or output
. This would allow both for the recording of simple macros as well as for more (the number of possible mappings is vastly increased) and ergonomically improved (no Emacs pinky) key mappings.
I don't know Rust, but I will try and take time to see if I can hack this together. Might be better implemented as a non-hack, however.
Would it be possible to add Hyper_L?
I would like to use Hyper as Mod3 in Sway.
Something like:
[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_LEFTHYPER"]
tap = ["KEY_ESC"]
I wrote a GUI editor for Evremap config files in Tauri (typescript,react,rust).
Lines 403 to 416 in d0e8eb2
There is imwheel tool for X11, that allows you to remap mouse wheel events combined with keyboard modifiers. I am looking for this functionality on wayland.
The problem is that afaik, this tool (evremap) currently only allow you to map a single device, while thing that I want requires two devices.
This works (remaps mouse button):
device_name = "Logitech MX Master"
[[remap]]
input = ["BTN_RIGHT"]
output = ["KEY_PAGEUP"]
This also works (remaps keyboard combination):
device_name = "Logitech K850"
[[remap]]
input = ["KEY_LEFTALT", "KEY_UP"]
output = ["KEY_PAGEUP"]
But such thing does not work:
device_name = ["Logitech MX Master", "Logitech K850"]
[[remap]]
input = ["KEY_LEFTALT", "BTN_RIGHT"]
output = ["KEY_PAGEUP"]
because device_name is expected to be a string.
Can we hope such functionality will be implemented?
currently i have to disconnect my external keyboard after rebooting from a hibernated state
Is it possible to use the same configuration for several input devices?
Ideally sth like:
config.toml
evremap mapper config.toml
and it starts acting on both A and BIf the above was possible, I wonder how connecting/disconnecting either of A/B would affect the process?
So, I have a TV remote, which is connected over a USB 2.4GHz dongle, and the remote does not have some important keys such as Shift, Control, Alt, Tab and Meta. So I use evremap to map these keys to the keys that are on the remote. The remote is plugged into the dock for my laptop - meaning, its only connected to my laptop when I am home. However, a laptop is still, very obviously, a laptop, so its not out of ordinary for it to be turned on when i am on the go - like, on a lecture in the university or something. And if the laptop is turned on elsewhere and then I get back home, the mappings do not work, because at the time of startup evremap's systemd service did not see the remote's usb dongle and emulated input devices plugged in.
This can happen with any scenario when any laptop is connected to an input device, but not permanently: people who use their Thinkpads as workstations when they are home (like me), people who sometimes connect a USB keyboard for some couch gaming, people who try to use evremap with bluetooth input methods and their bluetooth input method just ran out of battery or wasn't on when their computer was starting, etc.
There should be some built in way to wait for the needed device to connect, IMHO. For a convenience tool that evremap is, making it more convenient is only better, right?
I'm trying to disable my airplane mode key on my keyboard, and remap it to the right arrow key. I have tried:
[[remap]]
input = ["KEY_RFKILL"]
output = ["KEY_RIGHT"]
and
[[dual_role]]
input = "KEY_RFKILL"
hold = ["KEY_RIGHT"]
tap = ["KEY_RIGHT"]
Neither one works, but other keys are able to be remapped just fine. According to evremap list-keys
, this should be a valid remapping.
Running rfkill list
indicates that the airplane mode key causes the wifi to only be soft blocked, so it should be able to be remapped. When I run xev
, the airplane mode key corresponds to XF86RFKILL (keycode 255). If I do something like xmodmap -e "keycode 255 = Right"
, the key still turns off and on my wifi, while also functioning as a right arrow key, which is not what I want. My OS is Garuda Linux with Qtile, which is Arch-based. Any help would be appreciated.
hey this project looks great!
But, I've tried a few remaps and things are not working
this is my config:
# Run `sudo evremap list-devices` to see the devices available
# on your system.
device_name = "BT5.0 KB Keyboard"
[[remap]]
input = ["KEY_LEFTALT", "KEY_BACKSPACE"]
output = ["KEY_DELETE"]
and this was the command and output ( my config file is inside the repo)
evremap [ master][!?][📦 v0.1.0][🦀 v1.69.0] Sat, May 13, 2023 | 00:31
❯ sudo ./target/release/evremap remap ./config.toml
2023-05-13T00:33:42.354 ERROR evremap > Short delay: release any keys now!
2023-05-13T00:33:44.645 ERROR evremap::remapper > Going into read loop
pls let me know if I can be of help, or if I am doing something wrong
when i remap a key event on my touch pen, it works in the tty, but doesnt seem to work in a wayland compositor(i tried hyprland and sway). it is still registered by evtest and wev as the right key event, but applications seem to ignore it.
What would be the viability (with the current implementation)
of enabling an additional "double-tap" role in addition to
the current "hold" vs "tap" mappings?
Thank you for this tool!
Lenovo removed the context menu key 😢. See: https://askubuntu.com/questions/234416/how-to-remap-the-context-menu-to-another-key-in-linux.
I'm trying to remap function + right control
, key combination, to open right click context menu
. But it does not seem to work. Here's my setup:
$ which evremap
/usr/bin/evremap
$ evremap --version
evremap 0.1.0
$ sudo evremap list-devices | rg 'keyboard'
Name: AT Translated Set 2 keyboard
$ sudo evremap list-keys | rg 'CONTEXT'
KEY_CONTEXT_MENU
$ sudo evremap list-keys | rg 'MENU'
KEY_CONTEXT_MENU
KEY_MEDIA_TOP_MENU
KEY_MENU
KEY_ROOT_MENU
$ sudo evremap list-keys | rg 'FN$'
KEY_FN
$ sudo evremap list-keys | rg 'CTRL'
KEY_LEFTCTRL
KEY_RIGHTCTRL
and /etc/evremap.toml
device_name = "AT Translated Set 2 keyboard"
[[remap]]
input = ["KEY_FN", "KEY_RIGHTCTRL"]
output = ["KEY_CONTEXT_MENU"]
but when running the tool
$ sudo /usr/bin/evremap remap /etc/evremap.toml
2023-11-01T22:31:01.958 WARN evremap > Short delay: release any keys now!
2023-11-01T22:31:04.409 INFO evremap::remapper > Going into read loop
^C
All the other keyboard shortcuts (alt+tab, switch windows) glitch and the context menu does not appear on pressing the re-mapped key combination. How do I resolve this?
Cannot make it run under Archlinux.
my config:
device_name = "AT Translated Set 2 keyboard"
[[remap]]
input = ["KEY_LEFTCTRL"]
output = ["KEY_CAPSLOCK"]
[[remap]]
input = ["KEY_CAPSLOCK"]
output = ["KEY_LEFTCTRL"]
Running the command
sudo evremap remap ./code-kbd.conf
2022-03-12T23:47:49.075 ERROR evremap > Short delay: release any keys now!
Error: creating UInputDevice from /dev/input/event3
Caused by:
ENODEV: No such device
List of devices:
sudo evremap list-devices
Name: AT Translated Set 2 keyboard
Path: /dev/input/event3
Phys: isa0060/serio0/input0
Name: HDA Intel PCH Dock Headphone
Path: /dev/input/event9
Phys: ALSA
Name: HDA Intel PCH Dock Mic
Path: /dev/input/event7
Phys: ALSA
Name: HDA Intel PCH HDMI/DP,pcm=10
Path: /dev/input/event15
Phys: ALSA
Name: HDA Intel PCH HDMI/DP,pcm=3
Path: /dev/input/event11
Phys: ALSA
Name: HDA Intel PCH HDMI/DP,pcm=7
Path: /dev/input/event12
Phys: ALSA
Name: HDA Intel PCH HDMI/DP,pcm=8
Path: /dev/input/event13
Phys: ALSA
Name: HDA Intel PCH HDMI/DP,pcm=9
Path: /dev/input/event14
Phys: ALSA
Name: HDA Intel PCH Headphone
Path: /dev/input/event10
Phys: ALSA
Name: HDA Intel PCH Mic
Path: /dev/input/event8
Phys: ALSA
Name: Lid Switch
Path: /dev/input/event0
Phys: PNP0C0D/button/input0
Name: PC Speaker
Path: /dev/input/event4
Phys: isa0061/input0
Name: Power Button
Path: /dev/input/event2
Phys: LNXPWRBN/button/input0
Name: Sleep Button
Path: /dev/input/event1
Phys: PNP0C0E/button/input0
Name: SynPS/2 Synaptics TouchPad
Path: /dev/input/event16
Phys: isa0060/serio1/input0
Name: TPPS/2 IBM TrackPoint
Path: /dev/input/event17
Phys: synaptics-pt/serio0/input0
Name: ThinkPad Extra Buttons
Path: /dev/input/event6
Phys: thinkpad_acpi/input0
Name: Video Bus
Path: /dev/input/event5
Phys: LNXVIDEO/video/input0
Any idea what's going wrong?
I have evremap
set up for my bluetooth keyboard which is sometimes not connected at all. So, systemd
ends up restarting evremap
once a couple of seconds which ends up increasing PIDs on my entire system after some time. I think this is not ideal and some mechanism for waiting on connection could be good?
When trying to set things up to run w/o sudo
, I encountered the following issue, after following the instructions in https://github.com/wez/evremap#running-it
Most commands, like evremap list-devices
, would work fine.
BUT evremap remap ...
fails with:
Error: creating UInputDevice from /dev/input/event23
Caused by:
EACCES: Permission denied
After some debugging, I found this is due to the permissions in /dev/uinput
,
which in my system (Fedora) were:
crw-------. 1 root root 10, 223 Nov 5 18:22 /dev/uinput
That's despite having defined the rule with
echo 'KERNEL=="uinput", GROUP="input"' | sudo tee /etc/udev/rules.d/input.rules
I found this related issue,
by which it seems in some systems the rule might not trigger:
chrippa/ds4drv#93 (comment)
However, the solution proposed there did not work either for me.
As a workaround, I can do this:
sudo chgrp input /dev/uinput
sudo chmod 660 /dev/uinput
But it would be nice to get the rule-based approach to work.
If someone hits the same issue or has some idea on how to resolve, please let me know!
I couldn't think of a better description...
I'm using a HP Spectre laptop with a UK keyboard in the UK.
When I load this:
[ids]
*
[main]
# Maps capslock to escape when pressed and control when held.
### capslock = overload(control, esc)
# Remaps the escape key to capslock
### esc = capslock
rightcontrol = \
### |\
I get '#
' for [rightcontrol
] and '~
' for [shift+rightcontrol
].
I get some other weirdness - like '£
' for [#
].
The keyboard is essentially this:
Except, there's no [\ & |
] key immediately to the right of the [leftshift
] key.
I figured for a moment that there was some mismatch between US and UK keyboards because the US [\ & |
] key is where the UK [# & ~
] key is - but, when I substituted in the '#
' instead of '\
' I got the '£
' which seems to debunk that theory.
Obviously, I'm trying to map the missing [\ & |
] key to the [rightcontrol
] key - which is what is actually written on the [rightcontrol
] key on my keyboard.
Wonderful utility! Could we add a function to swap keys that doesn't cause loops, i.e. swap KEY_CAPSLOCK
and KEY_LEFTCTRL
.
For example, I'd like the physical CAPSLOCK
key to do the dual_role, and the physical LEFTCTRL
to emit CAPSLOCK.
This doesn't work as intended:
[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_LEFTCTRL"]
tap = ["KEY_ESC"]
[[remap]]
input = ["KEY_LEFTCTRL"]
output = ["KEY_CAPSLOCK"]
I understand I can do something like:
[[dual_role]]
input = "KEY_CAPSLOCK"
hold = ["KEY_LEFTCTRL"]
tap = ["KEY_ESC"]
[[dual_role]]
input = "KEY_LEFTCTRL"
hold = ["KEY_LEFTCTRL"]
tap = ["KEY_CAPSLOCK"]
But I can still see some use case for a real swapping. Perhaps a way to specify the original "physical" key?
Hi,
I am using Sway and XKB to switch between my keyboard layouts (TH and US).
This had been working out of the box since I installed Sway on my laptop until I ran evremap.
This is the XKB configuration part of my Sway configuration:
input "1:1:AT_Translated_Set_2_keyboard" {
xkb_layout us,th
xkb_model pc105
xkb_options grp:alt_space_toggle
}
As you can see, Alt+Space is supposed to change my keyboard layout.
And here is my evremap config (whole file):
device_name = "AT Translated Set 2 keyboard"
[[dual_role]]
input = "KEY_SYSRQ"
hold = ["KEY_RIGHTMETA"]
tap = ["KEY_PRINT"]
The remap works. But whenever I start evremap.service
, the xkb toggle stops working.
The toggle starts working again if I stop evremap.service
.
I thought this was a common problem, but after searching in Issues, I don't see others similar to this.
I would appreciate any helps, thank you very much!
is there a key for quotation marks ? cant find in list-keys
A cursory Google search hasn't shown an easy way to translate scancodes or X keycodes (obtained from xev running under XWayland) to the keycode string that the config expects. I've been tryong to remap the (<>) key (left of Z on my Model M 122) to Super. A simple command that just prints the pressed keycode to stdout until EOF would be very appreciated.
Edit: Further searching shows that the evtest
program already implements this. Leaving this here for anyone searching for the solution in the future, close the issue if you'd like.
The key code was the very descriptive KEY_102ND
, if you're curious.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.