<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>Shukry Zablah</title> <link>https://shukryzablah.com</link> <atom:link href="https://shukryzablah.com/rss.xml" rel="self" type="application/rss+xml" /> <language>en-us</language> <pubDate>Tue, 13 Oct 2026 01:11:19 +0000</pubDate> <item> <title>Emacs wakes up small: reporting an issue in the WSLg repository</title> <link>https://shukryzablah.com/posts/emacs-wakes-up-small-reporting-an-issue-in-the-wslg-repository.html</link> <pubDate>2026-09-04</pubDate> <author>Shukry Zablah</author> <guid isPermaLink="true">https://shukryzablah.com/posts/emacs-wakes-up-small-reporting-an-issue-in-the-wslg-repository.html</guid> <category><![CDATA[ wsl ]]></category><category><![CDATA[ debugging ]]></category> <description><![CDATA[ <p>There have been many times in which I have grabbed my laptop, opened it, and have seen my Emacs wake up tiny. This made working with WSL annoying, especially when using external displays. I never had time to figure it out ... until today.</p>

<!--more-->

<p>Every time this happened before, the only available mitigation had been to kill WSL entirely with <code>wsl --shutdown</code>. This meant frequently preparing to close my editor, and to kill my development servers. It slowed me down enough to be annoying, not enough to warrant me looking into it.</p>

<p><img src="https://storage.shukryzablah.com/img/wslg-tiny-emacs.png" alt="A full-screen terminal at normal size, with a Doom Emacs window about a quarter the size floating in the middle of it." /></p>

<h2>WSL: Linux in Windows</h2>

<p>I remember when I first learned about WSL. I didn't know it by name, nor was I able to use it. I only remember seeing a very captivating Windows Terminal app video.</p>

<p><iframe src="https://www.youtube.com/embed/8gw0rXPMMPE" frameborder="0" allowfullscreen></iframe></p>

<p><a href="https://www.youtube.com/watch?v=8gw0rXPMMPE" >The new Windows Terminal video posted May 6, 2019</a></p>

<p>I remember thinking it was a revolutionary concept. I had multiple times loaded Linux as an operating system on a handful of PCs, and I always found it annoying that it didn't have first class support in the systems that were available to me.</p>

<p>WSL is short for Windows Subsystem for Linux. Below is a description of WSL 1 and WSL 2.</p>

<ul>
<li><strong>WSL 1</strong>: a translation layer rather than an actual Linux kernel. It's faster on files under /mnt/c/ since it reaches them directly, and it uses fewer resources because there's no VM.</li>
<li><strong>WSL 2</strong>: a real Linux kernel in a managed VM, with full syscall compatibility. Faster inside the Linux filesystem; WSL 1 can't run Docker containers, lacking a real kernel and full syscall support.</li>
</ul>

<h3>WSLg: Linux GUI Apps in Windows</h3>

<p>My daily driver for the past 2 years has been a Windows PC's Ubuntu WSL (because you can use multiple distros as easily as you have tabs in the terminal), with Doom Emacs being my primary development environment. Every time I open Ubuntu or Arch in the Windows Terminal and type <code>emacs</code>, an Emacs GUI window pops up. Previously this used to require a separate X server. Now, that is not necessary, and GUI applications &quot;just work&quot; in WSL. Below is how I have understood things:</p>

<ul>
<li>X Server: a middleman protocol that owns the screen, apps draw over the network, X is a dated approach to graphical user interfaces in Linux. You need a separate solution for window management and for the compositor.</li>
<li>Wayland: a protocol that supersedes X, which lets apps talk directly to the compositor which also takes care of window management and display.</li>
<li>Weston: the reference implementation of the Wayland protocol, minimal and chosen by Microsoft to use for their WSL.</li>
<li>WSLg: a distro that runs in the same place the user distro runs, in charge of running audio, compositor, X translation layer, and the supervisor in charge of those.</li>
</ul>

<p>In summary, if I open the Arch distro in WSL, and type <code>emacs</code>, it will let the app talk directly via sockets to the WSLg distro, which is running the compositor, and it hands the information over sockets to the Windows Remote Desktop client, which treats each of those GUI apps as independent native Windows windows.</p>

<h2>The bug: a scale factor of zero</h2>

<p>The fact that Emacs is the only GUI application that I was using in WSL all this time made me initially think that it was related to Emacs in WSL. However, a telling piece of information was that the mitigation I knew wasn't <code>pkill emacs</code>, but instead <code>wsl --shutdown</code>. This pointed in the direction of WSL, and less so the specific application that I was using.</p>

<p>This morning I did an agent search of the problem, and stumbled upon the logs that spelled out my issue (WSLg runs the Weston compositor with an RDP backend, and <code>/mnt/wslg/weston.log</code> records the monitor layout the Windows client sends it):</p>

<p>A 'healthy' log:</p>

<pre><code>rdpMonitor[0]: desktopScaleFactor:250, deviceScaleFactor:180
Head mode change:rdp-0 NEW width:3456, height:2160, scale:2</code></pre>

<p>An 'unhealthy' log:</p>

<pre><code>rdpMonitor[0]: desktopScaleFactor:0, deviceScaleFactor:0
Head mode change:rdp-0 NEW width:3456, height:2160, scale:1</code></pre>

<p>The zero values are what change the output to be scale 1 on my HiDPI panel, so everything renders at half size — and the wrong number lives in the compositor, which is why relaunching Emacs gets you another tiny Emacs.</p>

<p>The agent search also correlated the bad layout log timing with the Windows event log, which let me know that the bad layout arrives a second after the machine <em>enters</em> standby, not when it leaves. The damage is done on the way down; I just didn't see it until returning to my computer.</p>

<p>Concretely, the cause is two lines in <code>libweston/backend-rdp/rdpdisp.c</code>:</p>

<pre><code><span class="code"><span class="symbol">if</span> <span class="paren1">(<span class="code">config-&gt;attributes.desktopScaleFactor == 0.0</span>)</span>
        <span class="symbol">return</span> 1.0f;</span></code></pre>

<p>A client reporting zero means &quot;I don't know yet.&quot; Weston reads it as &quot;100%.&quot;</p>

<h2>The fix: restart the RDP client</h2>

<p>The fix, from PowerShell:</p>

<pre><code>Stop-Process -Name msrdc -Force</code></pre>

<p>WSLg reconnects, sends a real scale factor, and everything snaps back. About a second.</p>

<p>Filed as <a href="https://github.com/microsoft/wslg/issues/1504" >microsoft/wslg#1504</a>.</p>
 ]]></description> </item><item> <title>Hi, this site is running in Coleslaw</title> <link>https://shukryzablah.com/posts/hi-this-site-is-running-in-coleslaw.html</link> <pubDate>2026-09-03</pubDate> <author>Shukry Zablah</author> <guid isPermaLink="true">https://shukryzablah.com/posts/hi-this-site-is-running-in-coleslaw.html</guid> <category><![CDATA[ meta ]]></category><category><![CDATA[ lisp ]]></category> <description><![CDATA[ <p>This site is running on something called Coleslaw. Because in a world in which AI can figure out the messy bits, it only makes sense to grasp at the fun bits. </p>

<!--more-->

<p>This is my personal site. From time to time I plan to write down snippets of my own experiences online across a variety of topics. I'm a Catholic born in El Salvador, and a software engineer. As a result, some of the snippets will be less understandable, you can always reach out to me over one of the socials linked to this site.</p>

<h1>Static site generators</h1>

<p>I wanted to give a brief overview of the technology that I chose to generate this site. As you might know, a site is just a bunch of html, css, and javascript (although nowadays it feels like they're mostly JS). To run this site I chose a static site generator, which simply put is a site that knows all its content in advance, so can be packaged up in a very simple and straightforward way and served in probably the fastest manner a site can be served over the network. </p>

<p><img src="https://storage.shukryzablah.com/img/pagespeed-insights.png" alt="A pagespeed insight screenshot showing 100% performance" /></p>

<p>There are many static site generators. I have used many tools before, the previous version of this site was written in <a href="https://gohugo.io/" >Hugo</a>. For this project I decided to take a page from one of my old interests, Common Lisp's Coleslaw. It had been a while since I used Common Lisp and it was looking like this could be an easy way to get some exposure again. To that end, I wanted to write up here what I know about Coleslaw, to force myself to look at the internals. </p>

<h1>Coleslaw</h1>

<p>Coleslaw is many years old, and is relatively stable. It is comprised of a small core, and a patchable system for plugins. It's meant to be used by an individual for their own site. </p>

<p>I think that the best place to start is to understand the main function of the program. </p>

<pre><code><span class="code"><span class="paren1">(<span class="code"><i><span class="symbol">defun</span></i> main <span class="paren2">(<span class="code">repo-dir &amp;key oldrev <span class="paren3">(<span class="code">deploy t</span>)</span></span>)</span>
  <span class="string">"Load the user's config file, compile the blog in REPO-DIR into STAGING-DIR,
 and optionally deploy the blog to DEPLOY-DIR.
  OLDREV -- the git revision prior to the last push.
  DEPLOY -- when non-nil, perform the deploy. (default: t)"</span>
  <span class="paren2">(<span class="code">load-config repo-dir</span>)</span>
  <span class="paren2">(<span class="code">setf <span class="special">*last-revision*</span> oldrev</span>)</span>
  <span class="paren2">(<span class="code">load-content</span>)</span>
  <span class="paren2">(<span class="code">compile-theme <span class="paren3">(<span class="code">theme <span class="special">*config*</span></span>)</span></span>)</span>
  <span class="paren2">(<span class="code"><i><span class="symbol">let</span></i> <span class="paren3">(<span class="code"><span class="paren4">(<span class="code">dir <span class="paren5">(<span class="code">staging-dir <span class="special">*config*</span></span>)</span></span>)</span></span>)</span>
    <span class="paren3">(<span class="code">compile-blog dir</span>)</span>
    <span class="paren3">(<span class="code">when deploy
      <span class="paren4">(<span class="code">deploy dir</span>)</span></span>)</span></span>)</span></span>)</span></span></code></pre>

<p>The function effectively describes the high level pipeline that is comprised of five steps: </p>

<ol>
<li>load-config: Config in coleslaw will determine how the site behaves. It is read into memory, and stored in code. It is responsible for also loading the plugin system.</li>
<li>load-content: Content is stored as text, and this step is responsible for searching and identifying the content that will be ultimately displayed in the site.</li>
<li>compile-theme: Theming is what allows a site to look different while having the same structured content.</li>
<li>compile-blog: This is what takes the config, the theme, and the content, and processes it to create the output that will eventually be loaded directly by the browsers.</li>
<li>deploy: An optional step, takes the files that we have created, and puts it in what is going to be responsible of serving our site.</li>
</ol>

<p>I think that rather captures all of Coleslaw. If I were to explain the magic that makes the whole project worthwile, I'd probably point to the interesting use of the protocol and object system that makes all of it tick. </p>

<p>The document protocol is extended with posts and indexes, and allow for the possibility of creating new types as well. Additionally, clever use of the object system also allows for coleslaw to discover automatically through code. </p>

<pre><code><span class="code"><span class="paren1">(<span class="code"><i><span class="symbol">defun</span></i> load-content <span class="paren2">(<span class="code"></span>)</span>
  <span class="string">"Load all content stored in the blog's repo."</span>
  <span class="paren2">(<span class="code">do-subclasses <span class="paren3">(<span class="code">ctype content</span>)</span>
    <span class="paren3">(<span class="code">discover ctype</span>)</span></span>)</span>
  <span class="paren2">(<span class="code">update-content-metadata</span>)</span>
  <span class="paren2">(<span class="code">do-subclasses <span class="paren3">(<span class="code">itype index</span>)</span>
    <span class="paren3">(<span class="code">discover itype</span>)</span></span>)</span></span>)</span></span></code></pre>

<p>In all, I think that it is pretty impressive to have an extensible static site generator with a plugin system described so succintly. </p>
 ]]></description> </item> </channel> </rss>