blog/remap-keyboard-keys-using-evremap.html

237 lines
12 KiB
HTML
Raw Normal View History

2023-10-31 09:21:46 +00:00
<!DOCTYPE html>
<html lang="en-IN">
<head>
<title>Remap keyboard keys using evremap | Aiquiral's Blog</title>
<meta name="description" content="Sometimes a key on your keyboard stops working, and you may not have the time or motivation to fix it or get it fixed. Or maybe you just want to change how your keyboard keys work to improve your workflow. All this, and more, can be done with the help of evremap.">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href=/assets/logo/favicon.svg />
<link rel="stylesheet" href=/assets/css/style.css />
</head>
<body>
<div class="head">
<div class="line-top"></div>
<nav>
<ul class='nav-bar'>
<li class='logo'><a href=/index.html><img src=/assets/logo/favicon.svg /></a></li>
<input type='checkbox' id='check' />
<span class="menu">
<li><a href="https://blog.aiquiral.me">Home</a></li>
<li><a href="https://portfolio.aiquiral.me">Portfolio</a></li>
<li><a href="https://aiquiral.me/contact">Contact</a></li>
<li><a href="https://aiquiral.me/about">About</a></li>
<label for="check" class="close-menu">X</label>
</span>
<label for="check" class="open-menu"></label>
</ul>
</nav>
</div>
<div class="blog-post">
<h1 class="post-heading">Remap keyboard keys using evremap</h1>
<p class="post-date">21 May 2023 | Linux Guide</p>
<img src="/assets/posts/2023-05-21-remap-keyboard-keys-using-evremap/evremap.avif" class="featured" alt="A close-up view of a purple backlit keyboard with a transparent text overlay reading “evremap”." title="Remap keyboard keys using evremap"/>
<h2 id="content">Content</h2>
<ol start="0">
<li><a href="#introduction">Introduction</a></li>
<li>
<p><a href="#building-and-installing">Building and Installing</a></p>
<ol type="a">
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#building">Building</a></li>
<li><a href="#installing">Installing</a></li>
</ol>
</li>
<li><a href="#usage">Usage</a></li>
<li><a href="#other-options">Other Options</a></li>
<li><a href="#references">References</a></li>
</ol>
<h2 id="introduction">Introduction</h2>
<p>Sometimes a key on your keyboard stops working, and you may not have the time or motivation to fix it or get it fixed. Or maybe you just want to change how your keyboard keys work to improve your workflow. All this, and more, can be done with the help of <code class="language-plaintext highlighter-rouge">evremap</code> (<a href="https://github.com/wez/evremap">github.com/wez/evremap</a>).</p>
<p>It is a tool that can remap the keyboard inputs for Linux systems, made by <a href="https://github.com/wez/">Wez</a>. And because <code class="language-plaintext highlighter-rouge">evremap</code> targets the <code class="language-plaintext highlighter-rouge">evdev</code> layer of <code class="language-plaintext highlighter-rouge">libinput</code>, the remapping is effective system-wide in Wayland, X11 and the Linux console.</p>
<h2 id="building-and-installing">Building and Installing</h2>
<h3 id="prerequisites">Prerequisites</h3>
<p>Debian and its derivatives like Ubuntu require some prerequisites before we can build it. Use this command to install them:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install git cargo pkg-config libevdev-dev
</code></pre></div></div>
<p>RHEL and its derivates also require some prerequisites. Use the following command to install it:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dnf install git libevdev-devel
</code></pre></div></div>
<h3 id="building">Building</h3>
<p>First, clone the repository to any folder of your choice. I recommend the Downloads folder, as after building it, you can safely delete it.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd ~/Downloads &amp;&amp; git clone https://github.com/wez/evremap.git &amp;&amp; cd evremap
</code></pre></div></div>
<p>Now, build the binary.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cargo build --release
</code></pre></div></div>
<p>If everything went fine, the last lines of your terminal output should be something like the ones in the image below.</p>
<p><img src="/assets/posts/2023-05-21-remap-keyboard-keys-using-evremap/evremap_build-finish.avif" alt="A screenshot of the terminal after evremap finished building." title="evremap_build-finish" class="inline-img" /></p>
<h3 id="installing">Installing</h3>
<p>Copy the binary file to the specified location using this command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo cp target/release/evremap /usr/bin/
</code></pre></div></div>
<p>Now create a config file in the specified location using this command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo touch /etc/evremap.toml
</code></pre></div></div>
<p>We will edit this file in the Usage section, below.To make your configured remapping active immediately after the system startup we need to create a <code class="language-plaintext highlighter-rouge">systemd</code> service. Use the following commands to do so:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo cp evremap.service /usr/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable evremap.service
sudo systemctl start evremap.service
</code></pre></div></div>
<p>Now, you can safely delete the cloned repository.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd .. &amp;&amp; rm -rf evremap
</code></pre></div></div>
<h2 id="usage">Usage</h2>
<p>In the configuration file, we need to state two things, basically name of the keyboard(s) and name of the keys you wish to remap.</p>
<p>To find the name of all the connected keyboards use the following command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo evremap list-devices
</code></pre></div></div>
<p>Usually, laptop keyboards will be named “AT Translated Set 2 keyboard”.</p>
<p>To find the name of all the inputs use:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo evremap list-keys
</code></pre></div></div>
<p>The <code class="language-plaintext highlighter-rouge">grep</code> command can help you find the keyboards and the keys faster.</p>
<p>For example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo evremap list-devices | grep HOME
</code></pre></div></div>
<p>Now, let us modify the configuration file. Use the following command to edit it:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo nano /etc/evremap.toml
</code></pre></div></div>
<p>Here is a template that you can copy and paste, and make te changes you need:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>device_name = "DEVICE NAME HERE"
[[remap]]
input = ["NAME_OF_THE_KEY_YOU_WILL_PRESS_ON_YOUR_KEYBOARD"]
output = ["NAME_OF_THE_KEY_YOU_NEED_TO_BE_PRESS_AS_THE_OUTPUT"]
[[remap]]
input = ["KEY_COMBINATION_1", "KEY_COMBINATION_2"]
output = ["OUTPUT_KEY"]
[[dual_role]]
input = "KEY_YOU_NEED_TO_CHANGE_THE_RESULT_FOR"
hold = ["KEY_THAT_WILL_BE_PRESSED_WHEN_INPUT_KEY_IS_HELD"]
tap = ["KEY_THAT_WILL_BE_PRESSED_WHEN_INPUT_KEY_IS_TAPPED"]
</code></pre></div></div>
<p>Here is the configuration file that I use for my laptop, as my Tab and Number 2 keys do not work.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>device_name = "AT Translated Set 2 keyboard"
[[remap]]
input = ["KEY_END"] output = ["KEY_2"]
[[remap]]
input = ["KEY_HOME"]
output = ["KEY_TAB"]
</code></pre></div></div>
<p>You can save the file by hitting CTRL + X, then Y and then Enter.</p>
<p>Now, you can log out and log back in and test your new configuration. If everything went perfectly, your remapped keys should work as expected.</p>
<p>Please visit the <a href="https://github.com/wez/evremap">official repository on GitHub</a> if you have any questions or need a detailed documentation.</p>
<h2 id="other-options">Other Options</h2>
<p>There is a tool called <code class="language-plaintext highlighter-rouge">xmodmap</code>, but it works only on X11.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://github.com/wez/evremap">https://github.com/wez/evremap</a></li>
</ul>
</div>
<div class="comments">
<hr>
<h2>Comments</h2>
<script>
var remark_config = {
host: 'https://comments.aiquiral.me',
site_id: 'blog',
}
</script>
<script>!function(e,n){for(var o=0;o<e.length;o++){var r=n.createElement("script"),c=".js",d=n.head||n.body;"noModule"in r?(r.type="module",c=".mjs"):r.async=!0,r.defer=!0,r.src=remark_config.host+"/web/"+e[o]+c,d.appendChild(r)}}(remark_config.components||["embed"],document);</script>
<div id="remark42"></div>
</div>
<div class="comments">
<h2>Recent Posts</h2>
<div class="all-posts-table"><div class="allposts-post">
<a href="/bypass-cgnat">
<img src="/assets/posts/2023-10-07-bypass-cgnat/bypass-cgnat.avif" class="latest" />
<h3 style="color: #25252d;">How to Bypass CGNAT - Exposing your home server to the internet with TLS/SSL pass through</h3>
<p>07 October 2023 | Linux Guide, Privacy, Self-hosting</p>
<p>You've set up a home server, and are hosting some services like Vaultwarden, or Jellyfin, or perhaps Nextcloud. But now, you want to share it...</p>
<p style="color: #2ea3f2;">Read More</p>
</a>
</div><div class="allposts-post">
<a href="/remap-keyboard-keys-using-evremap">
<img src="/assets/posts/2023-05-21-remap-keyboard-keys-using-evremap/evremap.avif" class="latest" />
<h3 style="color: #25252d;">Remap keyboard keys using evremap</h3>
<p>21 May 2023 | Linux Guide</p>
<p>Sometimes a key on your keyboard stops working, and you may not have the time or motivation to fix it or get it fixed. Or...</p>
<p style="color: #2ea3f2;">Read More</p>
</a>
</div><div class="allposts-post">
<a href="/proton-vpn-linux-guide">
<img src="/assets/posts/2023-05-19-proton-vpn-linux-guide/proton.svg" class="latest" />
<h3 style="color: #25252d;">Proton VPN Linux Guide How to install, configure, use and auto-connect?</h3>
<p>19 May 2023 | Linux Guide, Privacy</p>
<p>The official Proton VPN Linux client lacks a lot of features, like changing the connection protocol, quickly connecting to the fastest server of a specific...</p>
<p style="color: #2ea3f2;">Read More</p>
</a>
</div></div>
</div>
<div class="foot"><p style="text-align: center;"><a href="https://soundcloud.com/aiquiral">Music</a> <a href="https://git.aiquiral.me/aiquiral">Other Projects</a> <img src=/assets/logo/inline-logo.svg style="position:relative;bottom:-3px" width=28 height=32></img> <a href="https://aiquiral.me/privacy-policy.html">Privacy Policy</a> <a href="https://aiquiral.me/about.html">About</a></p></div>
<div class="line-bottom"></div>
</body>
</html>