<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Colas.Nahaboo.net - c</title>
    <subtitle>Colas Nahaboo personal site, with discussions about programming code, web and computing topics, surfing and SUPing, and various musings.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://colas.nahaboo.net/tags/c/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://colas.nahaboo.net"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-08-09T00:00:00+00:00</updated>
    <id>https://colas.nahaboo.net/tags/c/atom.xml</id>
    <entry xml:lang="en">
        <title>browser-freezer: freeze the browser when the screen blanks</title>
        <published>2026-08-09T00:00:00+00:00</published>
        <updated>2026-08-09T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://colas.nahaboo.net/code/browser-freezer/"/>
        <id>https://colas.nahaboo.net/code/browser-freezer/</id>
        
        <content type="html" xml:base="https://colas.nahaboo.net/code/browser-freezer/">&lt;img src=&#39;browser-freezer.jpg&#39;&gt;
&lt;p&gt;I have a small NUC-style mini PC that runs linux with X11, and I cannot suspend it — probably some hardware incompatibility or BIOS bug, as is often the case on these mini-PCs. So, to minimize power consumption and heat generation, I made &lt;strong&gt;&lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/ColasNahaboo/browser-freezer&quot;&gt;browser-freezer&lt;/a&gt;&lt;/strong&gt;: a small and light utility to freeze the browsers when the screen blanks, and un-freeze them on wakeup. On such a machine, the browser is the only thing consuming power when not being used.&lt;/p&gt;
&lt;h2 id=&quot;why-two-parts-c-bash&quot;&gt;Why two parts? C + bash&lt;a class=&quot;zola-anchor&quot; href=&quot;#why-two-parts-c-bash&quot; aria-label=&quot;Anchor link for: why-two-parts-c-bash&quot;&gt;🔗&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It is composed of two parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a tiny C daemon &lt;strong&gt;browser-freezer&lt;/strong&gt; that polls the state of the monitor (On / Off) with as less CPU usage as possible (no forks under X11)&lt;/li&gt;
&lt;li&gt;on monitor status change detection, it runs the bash script &lt;strong&gt;browser-freezer-signal&lt;/strong&gt; that sends the SIGSTOP or SIGCONT signal to all browser processes (firefox by default). It uses a bash script for the most possible flexibility and customization, as performance is not an issue there.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wayland&quot;&gt;Wayland&lt;a class=&quot;zola-anchor&quot; href=&quot;#wayland&quot; aria-label=&quot;Anchor link for: wayland&quot;&gt;🔗&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The initial release was X11 only, but two weeks later I added a Wayland variant: a second binary &lt;code&gt;browser-freezer-wayland&lt;/code&gt; and a wrapper that picks the right one at login depending on &lt;code&gt;$WAYLAND_DISPLAY&lt;/code&gt;. As always with Wayland, it is a second incompatible API to implement, but it works.&lt;/p&gt;
&lt;p&gt;My browsers are the only things consuming power on that machine when idle, so freezing them is the next best thing to suspending the whole PC. Indeed :-)&lt;/p&gt;
&lt;h2 id=&quot;installation-usage-and-more-info&quot;&gt;Installation, Usage, and more info&lt;a class=&quot;zola-anchor&quot; href=&quot;#installation-usage-and-more-info&quot; aria-label=&quot;Anchor link for: installation-usage-and-more-info&quot;&gt;🔗&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;See the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/ColasNahaboo/browser-freezer&quot;&gt;browser-freezer repository&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Some code and images generated by AI (Gemini), as my C was a bit rusty.&lt;/p&gt;
</content>
        
    </entry>
</feed>
