<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Wayland on foosel.net</title><link>https://foosel.net/tags/wayland/</link><description>Recent content in Wayland on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Mon, 09 Sep 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/wayland/index.xml" rel="self" type="application/rss+xml"/><item><title>How to override the EDID data of a monitor under Linux</title><link>https://foosel.net/til/how-to-override-the-edid-data-of-a-monitor-under-linux/</link><pubDate>Tue, 11 Apr 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/how-to-override-the-edid-data-of-a-monitor-under-linux/</guid><description>&lt;p&gt;I&amp;rsquo;m slowly but surely fixing all the issues I had after switching back to Linux as my main OS, so here&amp;rsquo;s another TIL 😉&lt;/p&gt;
&lt;p&gt;My secondary monitor is a 24&amp;quot; DELL with a resolution of 1920x1200, so 16:10, instead of the more common 1080p and 16:9. In order to be able to connect all my three monitors to my laptop, I make use of both the laptop&amp;rsquo;s HDMI port as well as a USB-C dock that has 2 HDMI ports. The 4k main display is connected directly to the laptop&amp;rsquo;s HDMI port, secondary and tertiary display are connected to the dock.&lt;/p&gt;</description><content:encoded><![CDATA[<p>I&rsquo;m slowly but surely fixing all the issues I had after switching back to Linux as my main OS, so here&rsquo;s another TIL 😉</p>
<p>My secondary monitor is a 24&quot; DELL with a resolution of 1920x1200, so 16:10, instead of the more common 1080p and 16:9. In order to be able to connect all my three monitors to my laptop, I make use of both the laptop&rsquo;s HDMI port as well as a USB-C dock that has 2 HDMI ports. The 4k main display is connected directly to the laptop&rsquo;s HDMI port, secondary and tertiary display are connected to the dock.</p>
<p>The problem now was that as long as I had both secondary and tertiary connected, I could only select up to 1080p for the secondary. That would not have been that big of an issue if that wouldn&rsquo;t have caused the monitor to try to scale the 16:9 output to 16:10, stretching it. With only the secondary display attached however, it would detect the 16:10 resolution just fine.</p>
<p>On Windows, with the same hardware setup (albeit a different laptop), this was quickly solved with <a href="https://www.monitortests.com/forum/Thread-Custom-Resolution-Utility-CRU">a third party tool</a> and ran just fine for months. On Linux I was stumped for the past few weeks since switching. Adding <code>video=</code> lines to the kernel parameters - as suggested by various guides - didn&rsquo;t seem to do the trick, and that appears to be the only option these days with Wayland in the mix to do something like this.</p>
<p>Today however I fell over <a href="https://wiki.archlinux.org/title/kernel_mode_setting#Forcing_modes_and_EDID">this helpful section</a> on the ArchLinux wiki, and that gave me an idea. Apparently the EDID information of the secondary is correct when it is connected alone, or I wouldn&rsquo;t be able to select 1920x1200 then. So I should be able to just grab the EDID data from it when working and force that to be used all the time via a kernel parameter.</p>
<p>I disconnected my tertiary display and verified the secondary was now again being detected as supporting 1920x1200. Then I first figured out its port by checking which of the available devices showed as connected (and wasn&rsquo;t the internal laptop screen or the 4k primary):</p>
<pre tabindex="0"><code>$ for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n &#34;${con#*/card?-}: &#34;; cat $p; done
DP-1: disconnected
DP-2: connected
DP-3: disconnected
DP-4: disconnected
DP-5: disconnected
DP-6: connected
DP-7: disconnected
eDP-1: connected
</code></pre><p>In my case that turned out to be <code>DP-6</code><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>. Next I quickly dumped the EDID information to a new file <code>/usr/lib/firmware/edid/dell-24-1200p.bin</code>:</p>
<pre tabindex="0"><code>sudo mkdir -p /usr/lib/firmware/edid
sudo cp /sys/class/drm/card1-DP-6/edid /usr/lib/firmware/edid/dell-24-1200p.bin
</code></pre><p>Then I used <code>grubby</code> to add a <code>drm.edid_firmware</code> kernel mode setting to all kernel entries for <code>DP-6</code> that tells the kernel to use this EDID file:</p>
<pre tabindex="0"><code>sudo grubby --update-kernel=ALL --args=&#34;drm.edid_firmware=DP-6:edid/dell-24-1200p.bin&#34;
</code></pre><p>And one reboot later I could finally select 1920x1200 for my display! 🥳</p>
<p><em>Addendum from 2023-05-24</em>*: Recently the display&rsquo;s identifier&rsquo;s started switching between <code>DP-6</code> and <code>DP-8</code>, sometimes even when waking up from sleep. I&rsquo;m not sure why, and I so far did not have time to investigate, but just so I or anyone else stumbling over this knows how to do this in the future, it&rsquo;s easy to set custom edid data on multiple devices as well, in my case:</p>
<pre tabindex="0"><code>sudo grubby --update-kernel=ALL --args=&#34;drm.edid_firmware=DP-6:edid/dell-24-1200p.bin,DP-8:edid/dell-24-1200p.bin&#34;
</code></pre><div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p><code>DP-2</code> is the primary and <code>eDP-1</code> the laptop&rsquo;s internal display&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item><item><title>How to remap keys under Linux and Wayland</title><link>https://foosel.net/til/how-to-remap-keys-under-linux-and-wayland/</link><pubDate>Fri, 03 Mar 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/how-to-remap-keys-under-linux-and-wayland/</guid><description>&lt;p&gt;&lt;em&gt;Edit 2024-09-09: Please be advised that this post refers to an older version of &lt;code&gt;keyd&lt;/code&gt; that still used a different configuration format. An older version also stated the config file was stored at &lt;code&gt;~/.config/keyd&lt;/code&gt;, that was an error on my part. Thanks to a reader for the related heads-up!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;As a German living in Germany with umlauts in my last name and a US ANSI keyboard layout on all my devices&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt; I need to remap some stuff to be able to easily type ä, ö, ü and ß. On Windows I solved this with &lt;a href="https://www.autohotkey.com/"&gt;Autohotkey&lt;/a&gt;, mapping &lt;code&gt;AltGr&lt;/code&gt;+&lt;code&gt;a&lt;/code&gt; to &lt;code&gt;ä&lt;/code&gt;, &lt;code&gt;AltGr&lt;/code&gt;+&lt;code&gt;o&lt;/code&gt; to &lt;code&gt;ö&lt;/code&gt;, &lt;code&gt;AltGr&lt;/code&gt;+&lt;code&gt;u&lt;/code&gt; to &lt;code&gt;ü&lt;/code&gt; and &lt;code&gt;AltGr&lt;/code&gt;+&lt;code&gt;s&lt;/code&gt; to &lt;code&gt;ß&lt;/code&gt; (well, technically &lt;code&gt;RAlt&lt;/code&gt; - the right &lt;code&gt;Alt&lt;/code&gt; key). That has burned itself into my muscle memory now, and so while currently setting up my new Framework laptop under Linux, with Gnome running on Wayland, I was looking for a way to remap the keys to this layout as well.&lt;/p&gt;</description><content:encoded><![CDATA[<p><em>Edit 2024-09-09: Please be advised that this post refers to an older version of <code>keyd</code> that still used a different configuration format. An older version also stated the config file was stored at <code>~/.config/keyd</code>, that was an error on my part. Thanks to a reader for the related heads-up!</em></p>
<p>As a German living in Germany with umlauts in my last name and a US ANSI keyboard layout on all my devices<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> I need to remap some stuff to be able to easily type ä, ö, ü and ß. On Windows I solved this with <a href="https://www.autohotkey.com/">Autohotkey</a>, mapping <code>AltGr</code>+<code>a</code> to <code>ä</code>, <code>AltGr</code>+<code>o</code> to <code>ö</code>, <code>AltGr</code>+<code>u</code> to <code>ü</code> and <code>AltGr</code>+<code>s</code> to <code>ß</code> (well, technically <code>RAlt</code> - the right <code>Alt</code> key). That has burned itself into my muscle memory now, and so while currently setting up my new Framework laptop under Linux, with Gnome running on Wayland, I was looking for a way to remap the keys to this layout as well.</p>
<p>In the old days, I would have written an <code>.Xmodmap</code> file and called it a day, but that no longer works under Wayland. Thankfully however there&rsquo;s a whole new generation of mapping tools that instead of depending on the X server allow remapping right at the kernel input level, and one of them is <a href="https://github.com/rvaiya/keyd">keyd</a> which I used to solve my umlaut problem, and while at it also added a fancy mod layer and even a mouse layer.</p>
<p>First of all, in Gnome I set the keyboard layout to &ldquo;English (intl., with AltGr dead keys)&rdquo;, making it look like this:</p>
<p><img alt="A screenshot of the US international keyboard layout in the Gnome Settings. It&rsquo;s visible that on the third level ä is on q, ö on p, ü on y and ß on s." loading="lazy" src="/til/how-to-remap-keys-under-linux-and-wayland/us-intl-layout.png"></p>
<p>Then I downloaded, compiled and installed <code>keyd</code> and created a config file at <code>/etc/keyd/default.cfg</code> with the following contents:</p>
<pre tabindex="0"><code>[ids]
*

[main]
capslock = layer(mod)
rightalt = layer(dia)
rightcontrol = overload(control, sysrq)

[dia]
a = G-q
o = G-p
u = G-y
s = G-s
e = G-5
` = G-S-;

[mod]
alt = layer(mouse)
j = left
k = down
l = right
i = up
u = home
o = end
y = pageup
h = pagedown
p = delete
; = insert

[mouse]
j = kp4
k = kp2
l = kp6
i = kp8
f = leftmouse
s = rightmouse
d = middlemouse
</code></pre><p>What this does is first of all attach  two layers <code>mod</code> and <code>dia</code> to <code>CapsLock</code> and right <code>Alt</code> respectively, and then it also gives the right <code>Ctrl</code> key a second purpose in life. Holding it still makes it act like your regular <code>Ctrl</code> key, but merely tapping it now will make it act like <code>PrintScreen</code> aka <code>SysRq</code>, allowing me to take screenshots more quickly than my laptop&rsquo;s keyboard layout would regularly allow<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup>.</p>
<p>But let&rsquo;s take a closer look at the layers.</p>
<h2 id="solving-my-umlaut-problem">Solving my umlaut problem</h2>
<p>Let&rsquo;s start with the <code>dia</code> layer, since that is what solves my umlaut problem. I couldn&rsquo;t get the compose key to work for me, so I went with mapping my desired shortcuts to the right shortcuts on the international layout for the key to pop up:</p>
<ul>
<li><code>a</code> -&gt; <code>AltGr</code>+<code>q</code> (<code>ä</code>)</li>
<li><code>o</code> -&gt; <code>AltGr</code>+<code>p</code> (<code>ö</code>)</li>
<li><code>u</code> -&gt; <code>AltGr</code>+<code>y</code> (<code>ü</code>)</li>
<li><code>s</code> -&gt; <code>AltGr</code>+<code>s</code> (<code>ß</code>)</li>
<li><code>e</code> -&gt; <code>AltGr</code>+<code>5</code> (<code>€</code>)</li>
<li><code>`</code> -&gt; <code>AltGr</code>+<code>Shift</code>+<code>;</code> (<code>°</code>)</li>
</ul>
<h2 id="adding-a-mod-layer">Adding a mod layer&hellip;</h2>
<p>While at it I decided to also add another feature I&rsquo;m used to from my UHK, and that is the Mod layer together with its arrow keys, home, end etc. So I replicated that as well, which is the <code>mod</code> layer here. And because I cannot remember a single time in my life where I ever needed <code>CapsLock</code>, that became my mod key. With Capslock held, we have the following mappings:</p>
<ul>
<li><code>j</code> -&gt; <code>left</code></li>
<li><code>k</code> -&gt; <code>down</code></li>
<li><code>l</code> -&gt; <code>right</code></li>
<li><code>i</code> -&gt; <code>up</code></li>
<li><code>u</code> -&gt; <code>home</code></li>
<li><code>o</code> -&gt; <code>end</code></li>
<li><code>y</code> -&gt; <code>pageup</code></li>
<li><code>h</code> -&gt; <code>pagedown</code></li>
<li><code>p</code> -&gt; <code>delete</code></li>
<li><code>;</code> -&gt; <code>insert</code></li>
</ul>
<p>I&rsquo;ve since also enabled <code>CapsLock</code> as <code>Mod</code> key on my UHK, in the hopes that this will accelerate my muscle memory learning process.</p>
<h2 id="-and-adding-a-mouse-layer-too">&hellip; and adding a mouse layer too!</h2>
<p>And then I thought, hm, can I maybe even add a mouse layer? And yes, I can. So I added a <code>mouse</code> layer, which is activated by holding <code>Alt</code> and <code>CapsLock</code> together. I enabled mouse keys in Gnome&rsquo;s accessibility settings, which allows me to move the mouse cursor with the numpad keys. My keyboard does not <em>have</em> numpad keys, but keyd doesn&rsquo;t care, and so we end up with this mapping:</p>
<ul>
<li><code>j</code> -&gt; move cursor left</li>
<li><code>k</code> -&gt; move cursor down</li>
<li><code>l</code> -&gt; move cursor right</li>
<li><code>i</code> -&gt; move cursor up</li>
<li><code>f</code> -&gt; left mouse button</li>
<li><code>s</code> -&gt; right mouse button</li>
<li><code>d</code> -&gt; middle mouse button</li>
</ul>
<p>I&rsquo;m not sure I&rsquo;ll actually use this a lot tbh, this was more a case of &ldquo;can it be done?&rdquo; and &ldquo;why not?&rdquo;. But it&rsquo;s nice to have the option. Something I still need to experiment on however are the acceleration settings, because out of the box this was way too slow for me, so after finding an answer <a href="https://askubuntu.com/a/1234995">here</a> I changed the mouse key parameters a bit via</p>
<pre tabindex="0"><code>gsettings set org.gnome.desktop.a11y.keyboard mousekeys-max-speed 2000;
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-init-delay 20;
gsettings set org.gnome.desktop.a11y.keyboard mousekeys-accel-time 2000;
</code></pre><p>But I&rsquo;m not 100% happy with this yet and need to play around with things a bit more.</p>
<h2 id="fixing-the-disable-touchpad-while-typing-feature">Fixing the &ldquo;Disable Touchpad while Typing&rdquo; feature</h2>
<p>One problem arose from all of this reconfiguration, and that was that the &ldquo;Disable Touchpad while Typing&rdquo; (DWT) feature was no longer working, which turned out to be a rather big deal - I kept unintentionally moving the cursor or even clicking on things while typing. Thankfully a quick search made me stumble over <a href="https://linuxtouchpad.org/libinput/2022/05/07/disable-while-typing.htmls">this helpful post</a> that not only explained the issue but also showed me how to solve it.</p>
<p>To summarize, DWT works by pairing up touchpad and keyboard either by them having the same vendor and product id, or being marked as &ldquo;internal&rdquo;. In the case of keyd acting as my keyboard, neither was true anymore and thus DWT no longer worked. The solution was to modify the <code>libinput</code> properties of the virtual keyd keyboard such that it would be marked as &ldquo;internal&rdquo;. Putting this into <code>/etc/libinput/local-overrides.quirks</code> sufficed:</p>
<pre tabindex="0"><code>[Virtual Keyboard]
MatchUdevType=keyboard
MatchName=keyd virtual keyboard
AttrKeyboardIntegration=internal
</code></pre><h2 id="conclusion">Conclusion</h2>
<p>keyd seems like a powerful tool, and even though I haven&rsquo;t actually yet tested it, should at any point I want to switch to X11 or a blank terminal on this laptop now, all these mappings should continue to function (as long as I set the keyboard layout to English international). That&rsquo;s definitely a way cleaner solution than the <code>xmodmap</code> approach I was using in the past. And I can now finally type my name again!</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>US ANSI layout is <em>so</em> much nicer for programming than the German ISO DE layout. I switched around three years ago when I got my first <a href="https://ultimatehackingkeyboard.com/">UHK</a> and haven&rsquo;t looked back.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:2">
<p>I tend take a <em>lot</em> of screenshots (mostly OctoPrint related), so this is a big deal for me.&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item></channel></rss>