<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Avinash</title>
    <description>The latest articles on DEV Community by Avinash (@avinash_bajpaii).</description>
    <link>https://dev.to/avinash_bajpaii</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2684020%2F4c813c06-d5f6-413f-ab37-9c4500686218.jpg</url>
      <title>DEV Community: Avinash</title>
      <link>https://dev.to/avinash_bajpaii</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/avinash_bajpaii"/>
    <language>en</language>
    <item>
      <title>I built a Dynamic Island for Windows in Electron. The hard part was CPU, not features</title>
      <dc:creator>Avinash</dc:creator>
      <pubDate>Mon, 23 Nov 2026 11:15:36 +0000</pubDate>
      <link>https://dev.to/avinash_bajpaii/i-built-a-dynamic-island-for-windows-in-electron-the-hard-part-was-cpu-not-features-2l4n</link>
      <guid>https://dev.to/avinash_bajpaii/i-built-a-dynamic-island-for-windows-in-electron-the-hard-part-was-cpu-not-features-2l4n</guid>
      <description>&lt;p&gt;Seven months ago I started building &lt;strong&gt;Smart Notch&lt;/strong&gt;, a small notch at the top of the Windows screen that expands when you hover over it. It shows what's playing, your CPU, RAM and battery, a focus timer and clipboard history. 230+ commits later it has passed 15,000 downloads on the Microsoft Store.&lt;/p&gt;

&lt;p&gt;Adding features turned out to be the easy part. The hard part was this: &lt;strong&gt;an always-on-top, transparent, animated window that runs all day must cost almost nothing when you aren't looking at it.&lt;/strong&gt; Early builds didn't. With the music visualizer open, one build used more than 20% of my laptop's CPU.&lt;/p&gt;

&lt;p&gt;Here is what I learned getting it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The window is bigger than the notch
&lt;/h2&gt;

&lt;p&gt;The visible pill is small, about 170–360 px wide when collapsed. But it has to grow into a large panel without the window resizing on every animation frame (resizing a transparent window is slow and flickers). So the notch lives inside one fixed, frameless, transparent window, and most of that window is empty.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;win&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BrowserWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;skipTaskbar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAlwaysOnTop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'screen-saver'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// stays above most windows&lt;/span&gt;
&lt;span class="n"&gt;win&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setIgnoreMouseEvents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The empty part must not block clicks on the apps underneath. &lt;code&gt;setIgnoreMouseEvents(true, { forward: true })&lt;/code&gt; makes the whole window click-through, but still forwards &lt;code&gt;mousemove&lt;/code&gt; events to the page. The renderer checks whether the pointer is over the pill. If it is, it tells the main process over IPC to make the window clickable again. When the pointer leaves, it switches back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// renderer (simplified)&lt;/span&gt;
&lt;span class="n"&gt;pill&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mouseenter'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ipc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'set-ignore-mouse-events'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;pill&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mouseleave'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ipc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'set-ignore-mouse-events'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. "Now playing" for every app
&lt;/h2&gt;

&lt;p&gt;Windows already knows what's playing: every media app that shows up in the volume flyout publishes a session to the &lt;strong&gt;System Media Transport Controls (SMTC)&lt;/strong&gt;. Reading SMTC means Spotify, a YouTube tab in Chrome, Apple Music and VLC all work without separate integrations.&lt;/p&gt;

&lt;p&gt;I read it in a separate Node worker process, so a slow call or a thumbnail decode never blocks the UI, and the worker only sends the renderer messages when something has changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Stop polling from PowerShell
&lt;/h2&gt;

&lt;p&gt;My first system-stats code was the obvious Windows approach: PowerShell scripts calling &lt;code&gt;Get-CimInstance&lt;/code&gt; in a loop. Each WMI call cost &lt;strong&gt;3–15 ms of CPU&lt;/strong&gt;, plus load on the &lt;code&gt;WmiPrvSE&lt;/code&gt; process, every few seconds, forever.&lt;/p&gt;

&lt;p&gt;Two changes removed that background cost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A small compiled C# helper&lt;/strong&gt; for native work (audio devices, window queries, media keys) instead of scripted loops.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Events instead of polling&lt;/strong&gt; where Windows offers them. For example, brightness changes come from the &lt;code&gt;WmiMonitorBrightnessEvent&lt;/code&gt; event instead of reading the value every second.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. The real lesson: you pay for frames drawn
&lt;/h2&gt;

&lt;p&gt;This was the surprise. I measured, and on my laptop (i5-1035G1, Intel UHD, 60 Hz) the cost of the UI came down to one number:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;About 0.6% of one CPU core for every frame per second Chromium draws.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The logic was cheap. Drawing was the cost. A UI that isn't animating costs about nothing, and a UI that animates at 60 fps costs a lot, &lt;em&gt;even if the movement is a fraction of a pixel&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here's what changed after rewriting the animations with that rule in mind:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;State&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Idle, collapsed&lt;/td&gt;
&lt;td&gt;2.9%&lt;/td&gt;
&lt;td&gt;~1.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Music playing, collapsed&lt;/td&gt;
&lt;td&gt;9.8%&lt;/td&gt;
&lt;td&gt;~2.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Expanded with visualizer&lt;/td&gt;
&lt;td&gt;21.5%&lt;/td&gt;
&lt;td&gt;~6.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(Task Manager-style %, all cores)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What made the difference:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Infinite JS animations → CSS.&lt;/strong&gt; Framer-motion loops that never ended were running JavaScript every frame. Moving them to CSS animations let Chromium's compositor run them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stepped easing for slow ambient motion.&lt;/strong&gt; A glow that drifts 20 px over 8 seconds still makes Chromium draw 60 frames a second. Using &lt;code&gt;steps()&lt;/code&gt; only draws a frame when the position actually changes by about a pixel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.glow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;drift&lt;/span&gt; &lt;span class="mi"&gt;8s&lt;/span&gt; &lt;span class="n"&gt;infinite&lt;/span&gt; &lt;span class="n"&gt;alternate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="cm"&gt;/* ~1 px per step for a 20 px move */&lt;/span&gt;
  &lt;span class="nl"&gt;animation-timing-function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(In the app I go one step further: a helper samples the real ease-in-out curve into &lt;code&gt;n&lt;/code&gt; jumps, so the motion keeps its easing.)&lt;/p&gt;

&lt;p&gt;The motion looks the same, and the GPU idles between steps. When several layers animate, give them a shared step clock so their frames line up instead of alternating.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No &lt;code&gt;backdrop-filter&lt;/code&gt; on a transparent window.&lt;/strong&gt; On a transparent always-on-top window, blur means re-reading the desktop behind it constantly. I removed it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't animate &lt;code&gt;&amp;lt;svg&amp;gt;&lt;/code&gt; roots.&lt;/strong&gt; Chromium doesn't put CSS transform animations on an &lt;code&gt;&amp;lt;svg&amp;gt;&lt;/code&gt; element onto the compositor. Wrap the SVG in a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and animate the div instead.&lt;/p&gt;

&lt;p&gt;A tip for checking: in DevTools, &lt;code&gt;document.getAnimations()&lt;/code&gt; shows every animation running right now. In an idle state that list should be empty.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Benchmarking "music playing" in silence
&lt;/h2&gt;

&lt;p&gt;I needed to measure the "music playing" state repeatedly without music playing through my speakers. The trick: a hidden window loops a generated &lt;em&gt;silent&lt;/em&gt; WAV file and sets &lt;code&gt;navigator.mediaSession.metadata&lt;/code&gt;. Windows registers that as a real media session, so the notch reacts exactly as it would to Spotify, and nobody has to listen to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Shipping it
&lt;/h2&gt;

&lt;p&gt;Smart Notch is packaged as an AppX with electron-builder and distributed through the &lt;strong&gt;Microsoft Store&lt;/strong&gt;, which handles updates and the optional one-time Pro purchase (synced lyrics, per-app volume mixer, file shelf, extra themes). The free version has everything in this post.&lt;/p&gt;

&lt;p&gt;If you want to try it or poke at how it behaves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft Store: &lt;a href="https://apps.microsoft.com/detail/9N1D46F5X565" rel="noopener noreferrer"&gt;https://apps.microsoft.com/detail/9N1D46F5X565&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Site: &lt;a href="https://smart-notch-windows.vercel.app/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=build_story" rel="noopener noreferrer"&gt;https://smart-notch-windows.vercel.app/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=build_story&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm curious what others have found keeping Electron overlays light. What would you measure next?&lt;/p&gt;

</description>
      <category>electron</category>
      <category>windows</category>
      <category>javascript</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
