<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Vishal Mahajan's Blog]]></title><description><![CDATA[Thoughts on tech, life, code, and everything I find worth sharing.]]></description><link>https://blog.vishalrmahajan.in</link><image><url>https://cdn.hashnode.com/uploads/logos/687e92dc46b382b26f74025d/22b88275-0d4a-450a-874f-771071954404.png</url><title>Vishal Mahajan&apos;s Blog</title><link>https://blog.vishalrmahajan.in</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Nov 2026 02:49:39 GMT</lastBuildDate><atom:link href="https://blog.vishalrmahajan.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Bringing Dell G15 Fan Control to Linux: Investigating `alienware_wmi` and Building a GNOME Extension]]></title><description><![CDATA[Build a Dell G15 fan-control utility on Ubuntu using alienware_wmi, Linux hwmon, Bash, and a custom GNOME Shell extension.]]></description><link>https://blog.vishalrmahajan.in/bringing-dell-g15-fan-control-to-linux-investigating-alienware-wmi-and-building-a-gnome-extension</link><guid isPermaLink="true">https://blog.vishalrmahajan.in/bringing-dell-g15-fan-control-to-linux-investigating-alienware-wmi-and-building-a-gnome-extension</guid><category><![CDATA[Linux]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[dell]]></category><category><![CDATA[Bash]]></category><category><![CDATA[Gnome]]></category><dc:creator><![CDATA[Vishal Mahajan]]></dc:creator><pubDate>Wed, 04 Nov 2026 18:23:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/9cdf1b74-e221-43ab-bf7d-59423f1e13e6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Gaming laptops have sophisticated thermal management systems. However, having access to the hardware does not always mean having convenient access to its controls.</p>
<p>The Dell G15 includes a dedicated G-mode key (F9) that activates rapid cooling in supported Windows configurations. When using Ubuntu on my Dell G15 5520, I wanted a similar way to monitor fan speeds, request maximum fan boost, and restore automatic fan operation.</p>
<p>The challenge was that Linux did not provide an equivalent convenient workflow in my tested setup.</p>
<p>Rather than attempting to recreate Dell's entire Windows thermal-management software, I decided to investigate the hardware interfaces already exposed by the Linux kernel.</p>
<p>The result was <strong>Dell G15 Fan Control</strong>, a Linux utility with three components:</p>
<ul>
<li>A command-line interface for monitoring and controlling the fans.</li>
<li>A privileged helper for hardware operations.</li>
<li>A GNOME Shell extension for desktop integration.</li>
</ul>
<p>This article documents the investigation, implementation, and testing process.</p>
<h2>1. Investigating the Hardware</h2>
<p>Before writing any code, I needed to understand how Linux exposed the laptop's fan controls.</p>
<p>Linux provides a hardware monitoring subsystem called <code>hwmon</code>. Drivers that support hardware monitoring expose their attributes through:</p>
<pre><code class="language-bash">ls /sys/class/hwmon/
</code></pre>
<p>My system returned:</p>
<pre><code class="language-text">hwmon0  hwmon1  hwmon2  hwmon3  hwmon4
hwmon5  hwmon6  hwmon7  hwmon8
</code></pre>
<p>The device numbers alone were not particularly useful. I needed to identify which hardware component each directory represented.</p>
<p>I used:</p>
<pre><code class="language-bash">for hwmon in /sys/class/hwmon/hwmon*; do
    echo "$(basename "$hwmon"): $(cat "$hwmon/name")"
done
</code></pre>
<p>The output from my Dell G15 5520 was:</p>
<pre><code class="language-text">hwmon0: AC
hwmon1: BAT0
hwmon2: nvme
hwmon3: ucsi_source_psy_USBC000:001
hwmon4: alienware_wmi
hwmon5: dell_ddv
hwmon6: dell_smm
hwmon7: iwlwifi_1
hwmon8: coretemp
</code></pre>
<p>The important discovery was <code>alienware_wmi</code>.</p>
<p>This indicated that the Linux kernel had registered an Alienware WMI hardware monitoring interface on the laptop.</p>
<p>The other interfaces exposed information for components such as the battery, NVMe storage, wireless adapter, and CPU temperatures.</p>
<p>For this project, <code>alienware_wmi</code> was the interface worth investigating further.</p>
<h2>2. Exploring the <code>alienware_wmi</code> Interface</h2>
<img src="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/7d6287d4-15a5-46b7-a481-beb32c8e099a.png" alt="2" style="display:block;margin:0 auto" />

<p>After identifying the relevant device, I inspected its contents:</p>
<pre><code class="language-bash">ls -l /sys/class/hwmon/hwmon4/
</code></pre>
<p>The directory contained several fan-related attributes:</p>
<pre><code class="language-text">fan1_boost
fan1_input
fan1_label
fan1_max
fan1_min

fan2_boost
fan2_input
fan2_label
fan2_max
fan2_min
</code></pre>
<p>There were also temperature-related attributes and additional hardware monitoring information.</p>
<p>The four attributes that mattered most were:</p>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td><code>fan1_input</code></td>
<td>Fan 1 speed</td>
</tr>
<tr>
<td><code>fan2_input</code></td>
<td>Fan 2 speed</td>
</tr>
<tr>
<td><code>fan1_boost</code></td>
<td>Fan 1 boost control</td>
</tr>
<tr>
<td><code>fan2_boost</code></td>
<td>Fan 2 boost control</td>
</tr>
</tbody></table>
<p>This was the key finding.</p>
<p>The kernel driver exposed both fan speed readings and writable boost controls. I could therefore build the application around an existing kernel interface instead of creating a separate hardware communication layer.</p>
<h3>Why Not Hardcode <code>hwmon4</code>?</h3>
<p>Linux assigns hwmon device numbers dynamically. Although <code>alienware_wmi</code> appeared as <code>hwmon4</code> on my machine, this number could change depending on device registration order.</p>
<p>A utility that assumes the interface will always exist at:</p>
<pre><code class="language-text">/sys/class/hwmon/hwmon4/
</code></pre>
<p>would be unnecessarily fragile.</p>
<p>The implementation therefore searches the available hwmon directories and identifies the device using its <code>name</code> attribute.</p>
<p>This allows the utility to locate <code>alienware_wmi</code> even when its assigned hwmon number changes.</p>
<h2>3. Understanding Fan Boost Controls</h2>
<p>Finding the boost attributes was only the first step. I also needed to understand their behaviour.</p>
<p>The driver exposed two writable attributes:</p>
<pre><code class="language-text">fan1_boost
fan2_boost
</code></pre>
<p>The implementation uses two values:</p>
<table>
<thead>
<tr>
<th>Value</th>
<th>Operation</th>
</tr>
</thead>
<tbody><tr>
<td><code>0</code></td>
<td>Automatic fan operation</td>
</tr>
<tr>
<td><code>255</code></td>
<td>Maximum fan boost request</td>
</tr>
</tbody></table>
<p>To request maximum boost on my current system:</p>
<pre><code class="language-bash">echo 255 | sudo tee /sys/class/hwmon/hwmon4/fan1_boost
echo 255 | sudo tee /sys/class/hwmon/hwmon4/fan2_boost
</code></pre>
<p>To restore automatic operation:</p>
<pre><code class="language-bash">echo 0 | sudo tee /sys/class/hwmon/hwmon4/fan1_boost
echo 0 | sudo tee /sys/class/hwmon/hwmon4/fan2_boost
</code></pre>
<p>Fan speeds can be read independently:</p>
<pre><code class="language-bash">cat /sys/class/hwmon/hwmon4/fan1_input
cat /sys/class/hwmon/hwmon4/fan2_input
</code></pre>
<p>These values are reported in RPM.</p>
<p><strong>Important:</strong> These commands use <code>hwmon4</code> because that was the interface number on my tested system. The project itself discovers the interface dynamically.</p>
<h3>A Note About the Control Mechanism</h3>
<p>It is important to distinguish a fan boost request from direct fan-speed control.</p>
<p>Writing <code>255</code> requests maximum boost through the driver. It does not specify an exact RPM target or implement a custom fan curve.</p>
<p>The actual fan speed remains subject to firmware and hardware behaviour.</p>
<p>Similarly, restoring <code>0</code> returns fan management to automatic firmware-controlled operation.</p>
<h2>4. Building the Command-Line Utility</h2>
<img src="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/3c68de78-cdb7-4e3f-bcb7-ad7b0ebe0a11.png" alt="3" style="display:block;margin:0 auto" />

<p>Once I understood the hardware interface, I wanted to avoid manually reading and writing sysfs attributes every time.</p>
<p>I implemented a Bash-based command-line utility named <code>dell-fanctl</code>.</p>
<p>The utility supports four commands:</p>
<pre><code class="language-bash">dell-fanctl status
dell-fanctl boost
dell-fanctl auto
dell-fanctl help
</code></pre>
<h3>4.1 Status Monitoring</h3>
<p>The status command reads the available hardware attributes and displays the current state.</p>
<pre><code class="language-bash">dell-fanctl status
</code></pre>
<p>Example output:</p>
<pre><code class="language-text">Dell Fan Control
-------------------------
Driver:       alienware_wmi
Interface:    hwmon4
Fan 1:        3955 RPM
Fan 2:        4246 RPM
Fan 1 boost:  255
Fan 2 boost:  255
Mode:         Maximum boost
</code></pre>
<p>The displayed RPM values are illustrative. Actual readings vary with workload, temperature, and firmware behaviour.</p>
<p>The utility determines the operating mode by examining both boost values:</p>
<ul>
<li>Both values are <code>0</code>: Automatic.</li>
<li>Both values are <code>255</code>: Maximum boost.</li>
<li>Different values: Mixed or custom state.</li>
</ul>
<h3>4.2 Maximum Boost</h3>
<pre><code class="language-bash">dell-fanctl boost
</code></pre>
<p>This invokes the privileged helper to request maximum boost for both fans.</p>
<h3>4.3 Automatic Mode</h3>
<pre><code class="language-bash">dell-fanctl auto
</code></pre>
<p>This restores automatic fan operation.</p>
<h3>4.4 Dynamic Hardware Discovery</h3>
<p>The CLI does not rely on a hardcoded hwmon number.</p>
<p>Instead, it iterates through:</p>
<pre><code class="language-text">/sys/class/hwmon/hwmon*
</code></pre>
<p>and checks each device's <code>name</code> attribute.</p>
<p>Once it finds <code>alienware_wmi</code>, it uses that directory to read fan speeds and boost values.</p>
<p>This makes the implementation more robust across reboots and changes in device registration order.</p>
<h2>5. Separating Hardware Access from the CLI</h2>
<p>The next problem was permissions.</p>
<p>Reading the fan attributes does not require the same privileges as writing to them. Hardware-control operations require elevated permissions.</p>
<p>Running the entire application as root would have been unnecessary.</p>
<p>I therefore separated the application into two scripts:</p>
<pre><code class="language-text">scripts/
├── fanctl
└── fanctl-write
</code></pre>
<table>
<thead>
<tr>
<th>Component</th>
<th>Responsibility</th>
</tr>
</thead>
<tbody><tr>
<td><code>fanctl</code></td>
<td>User-facing commands and hardware status</td>
</tr>
<tr>
<td><code>fanctl-write</code></td>
<td>Privileged fan-control operations</td>
</tr>
</tbody></table>
<p>The privileged helper accepts only two operations:</p>
<pre><code class="language-bash">fanctl-write boost
fanctl-write auto
</code></pre>
<p>It maps those operations to the corresponding boost values.</p>
<p>It also validates the hardware attributes before attempting writes. If the second fan operation fails after the first succeeds, it attempts to restore the previous value of the first fan.</p>
<p>This provides a basic rollback mechanism for partial failures.</p>
<h3>5.1 Avoiding Repeated Password Prompts</h3>
<p>A fan-control utility would be inconvenient if every button press required a password.</p>
<p>I used a dedicated sudoers configuration to permit only the two supported helper operations without a password.</p>
<p>The rule is restricted to the installed helper and its supported arguments.</p>
<p>The configuration is validated using:</p>
<pre><code class="language-bash">sudo visudo -c
</code></pre>
<p>This keeps privileged operations separate from the normal CLI and avoids granting unrestricted passwordless root access.</p>
<h2>6. Building the GNOME Shell Extension</h2>
<p>The command-line interface solved the functional problem, but I wanted fan control to be accessible directly from the desktop.</p>
<p>Since my Ubuntu installation uses GNOME, I built a GNOME Shell extension.</p>
<p>The extension adds a fan indicator to the top panel.</p>
<p>Its interface intentionally contains only the information and controls required for everyday use.</p>
<p>It displays:</p>
<ul>
<li>Fan 1 RPM.</li>
<li>Fan 2 RPM.</li>
<li>Current operating mode.</li>
</ul>
<p>It provides two controls:</p>
<table>
<thead>
<tr>
<th>Control</th>
<th>Operation</th>
</tr>
</thead>
<tbody><tr>
<td>Auto</td>
<td>Restores automatic fan operation</td>
</tr>
<tr>
<td>Max Boost</td>
<td>Requests maximum fan boost</td>
</tr>
</tbody></table>
<p>The extension refreshes fan readings periodically.</p>
<h3>Why Use the CLI as the Backend?</h3>
<p>Instead of implementing hardware discovery and privileged operations again inside JavaScript, the extension communicates with the existing CLI.</p>
<p>The architecture is:</p>
<pre><code class="language-text">           GNOME Shell
                |
                v
       GNOME Extension
                |
                v
           dell-fanctl
                |
                v
       Privileged Helper
                |
                v
          alienware_wmi
                |
                v
           Fan Controls
</code></pre>
<p>This keeps the hardware-control logic in one place.</p>
<p>The CLI and GNOME extension both use the same backend, reducing duplicated logic and making future maintenance easier.</p>
<h3>Wayland and Extension Discovery</h3>
<p>During installation, I encountered a GNOME-specific issue.</p>
<p>The extension files could be copied successfully, but GNOME Shell did not always discover the newly installed extension immediately.</p>
<p>On my Wayland session, restarting GNOME Shell through the traditional <code>Alt + F2</code>, followed by <code>r</code>, workflow was not available.</p>
<p>Logging out and logging back in allowed GNOME to discover the extension.</p>
<p>This behaviour was accounted for in the installation guidance.</p>
<h2>7. Installation and Uninstallation</h2>
<p>Once the backend and desktop integration were functional, I added installation and uninstallation scripts.</p>
<p>The installer handles:</p>
<ol>
<li>Hardware compatibility checks.</li>
<li>CLI installation.</li>
<li>Privileged helper installation.</li>
<li>Restricted sudoers configuration.</li>
<li>GNOME extension installation.</li>
<li>An attempt to enable the extension.</li>
</ol>
<p>Installation:</p>
<pre><code class="language-bash">git clone https://github.com/vishalrmahajan/dell-g15-fan-control.git
cd dell-g15-fan-control

chmod +x install.sh
./install.sh
</code></pre>
<p>The uninstaller restores automatic fan operation before removing the installed components.</p>
<pre><code class="language-bash">./uninstall.sh
</code></pre>
<p>It removes the GNOME extension, CLI, privileged helper, and project-specific sudoers configuration.</p>
<p>The repository source files are preserved.</p>
<h2>8. Testing</h2>
<p>Testing was performed on the actual Dell G15 5520, in addition to backend tests using mock hardware monitoring directories.</p>
<p>The test suite covers:</p>
<ul>
<li>Fan RPM readings.</li>
<li>Automatic mode.</li>
<li>Maximum boost mode.</li>
<li>Mixed fan states.</li>
<li>Missing hardware driver.</li>
<li>Missing boost attributes.</li>
<li>Invalid boost values.</li>
<li>Missing RPM attributes.</li>
<li>Dynamic hwmon device discovery.</li>
</ul>
<p>Run the test suite:</p>
<pre><code class="language-bash">bash tests/test-fanctl.sh
</code></pre>
<p>The backend test suite contains ten assertions.</p>
<p>I also tested the privileged writer separately to verify automatic and boost transitions without relying exclusively on the real hardware.</p>
<h3>Hardware Observations</h3>
<p>During testing, maximum boost produced readings of approximately:</p>
<table>
<thead>
<tr>
<th>Fan</th>
<th align="right">Observed speed</th>
</tr>
</thead>
<tbody><tr>
<td>Fan 1</td>
<td align="right">3955 RPM</td>
</tr>
<tr>
<td>Fan 2</td>
<td align="right">4246 RPM</td>
</tr>
</tbody></table>
<p>These are observed values from a test session, not fixed RPM targets.</p>
<p>In automatic mode, fan speeds varied with system conditions. This is expected because the firmware manages fan operation based on thermal requirements.</p>
<h2>9. Project Structure</h2>
<p>The final project is organized as follows:</p>
<pre><code class="language-text">dell-g15-fan-control/
├── docs/
│   ├── development-environment.txt
│   └── screenshots/
├── extensions/
│   └── dell-g15-fan-control/
│       ├── extension.js
│       └── metadata.json
├── scripts/
│   ├── fanctl
│   └── fanctl-write
├── tests/
│   └── test-fanctl.sh
├── install.sh
├── uninstall.sh
├── README.md
└── .gitignore
</code></pre>
<p>The separation between the backend, desktop integration, and installation scripts keeps the project manageable and makes individual components easier to test.</p>
<h2>10. Limitations and Future Work</h2>
<p>The current implementation has been tested on the Dell G15 5520 running Ubuntu 26.04.1 LTS with GNOME 50.</p>
<p>There are some limitations:</p>
<ul>
<li>Compatibility with other Dell G15 models has not yet been verified.</li>
<li>The utility depends on the fan-control attributes exposed by <code>alienware_wmi</code>.</li>
<li>Maximum boost requests the highest boost value exposed by the driver. It does not directly set an RPM target.</li>
<li>Custom fan curves are not implemented.</li>
<li>The utility does not replace the laptop's firmware thermal management.</li>
</ul>
<p>Potential future improvements include testing additional Dell G15 models, improving hardware compatibility detection, and extending desktop integration.</p>
<h2>Conclusion</h2>
<p>What started as an attempt to access the rapid cooling functionality of my Dell G15 from Ubuntu turned into a small Linux hardware-control project.</p>
<p>The most important part was not writing the fan-control commands. It was understanding the hardware monitoring interface exposed by the kernel, identifying the relevant attributes, and building a practical interface around them.</p>
<p>The project now provides fan monitoring and control through both the terminal and GNOME desktop, while keeping privileged hardware operations isolated in a dedicated helper.</p>
<p>It demonstrates how existing Linux kernel interfaces can be used to build practical hardware utilities without developing an entirely new driver.</p>
<p><strong>Repository:</strong> <a href="https://github.com/vishalrmahajan/dell-g15-fan-control">Dell G15 Fan Control</a></p>
<hr />
<p><em>Tested on Dell G15 5520, Ubuntu 26.04.1 LTS, GNOME 50.</em></p>
]]></content:encoded></item><item><title><![CDATA[One Bluetooth Pairing, Two Operating Systems: Fixing Windows - Ubuntu Dual-Boot Bluetooth on a Dell G15 5520]]></title><description><![CDATA[Fix Windows–Ubuntu dual-boot Bluetooth issues by sharing pairing keys using One Pair, Windows Registry, and Linux BlueZ.]]></description><link>https://blog.vishalrmahajan.in/one-bluetooth-pairing-two-operating-systems-fixing-windows-ubuntu-dual-boot-bluetooth-on-a-dell-g15-5520</link><guid isPermaLink="true">https://blog.vishalrmahajan.in/one-bluetooth-pairing-two-operating-systems-fixing-windows-ubuntu-dual-boot-bluetooth-on-a-dell-g15-5520</guid><category><![CDATA[Linux]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[Windows]]></category><category><![CDATA[bluetooth]]></category><category><![CDATA[- Dual Boot]]></category><category><![CDATA[dualboot]]></category><category><![CDATA[fix]]></category><dc:creator><![CDATA[Vishal Mahajan]]></dc:creator><pubDate>Mon, 02 Nov 2026 14:45:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/d9570211-62bd-493d-a7de-bc4cb5a7ea5c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>How I migrated a Windows Bluetooth pairing into Ubuntu using One Pair, BlueZ, and the Windows SYSTEM registry.</em></p>
<h2>The problem: why do I have to pair my earbuds twice?</h2>
<img src="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/5f3b1bcc-7d75-4171-b089-eaa541f85841.png" alt="1" style="display:block;margin:0 auto" />

<p>Running Windows and Linux on the same laptop is convenient, but dual-booting can introduce an irritating Bluetooth problem.</p>
<p>I paired my <strong>realme Buds Wireless 5 ANC</strong> with Windows on my Dell G15 5520. After rebooting into Ubuntu, the earbuds needed to be paired again. Pairing them in Ubuntu could then make Windows lose its existing connection.</p>
<p>The Bluetooth adapter was physically the same in both operating systems. The earbuds were the same. Yet the two operating systems behaved as though they were different computers.</p>
<p>The reason was not a faulty Bluetooth adapter or a problem with the earbuds. It was the way Windows and Linux maintained their Bluetooth pairing credentials.</p>
<p>Instead of repeatedly removing and pairing the earbuds, I wanted both operating systems to use the same Bluetooth credentials.</p>
<p>That led me to <a href="https://github.com/C6S/one-pair"><strong>One Pair</strong></a>, an open-source project that migrates Bluetooth pairing information from Windows into Linux's BlueZ database.</p>
<p>The result: I successfully connected the earbuds in Ubuntu after importing the Windows pairing, and verified that they continued to work when switching between Windows and Ubuntu.</p>
<p>This article documents the process, the technical details, the precautions, and the commands I used.</p>
<h2>1. Understanding the problem</h2>
<p>Bluetooth pairing is more than remembering a device's name and MAC address.</p>
<p>During pairing, the computer and the Bluetooth device establish cryptographic credentials. These credentials are subsequently used to authenticate and establish trusted connections.</p>
<p>Windows and Linux maintain their own Bluetooth pairing databases:</p>
<ul>
<li>Windows stores Bluetooth pairing information in its registry.</li>
<li>Linux, when using BlueZ, stores persistent Bluetooth device information under <code>/var/lib/bluetooth/</code>.</li>
</ul>
<p>Consequently, pairing a device in Windows does not automatically make that pairing available to Ubuntu.</p>
<h3>Why does pairing in one operating system affect the other?</h3>
<p>For classic Bluetooth (BR/EDR), the device and host use a link key for authentication.</p>
<p>A dual-boot laptop uses the same physical Bluetooth adapter in both operating systems. That adapter has a Bluetooth address, which acts as the host identity from the device's perspective.</p>
<p>The important detail is that the earbuds do not necessarily understand that Windows and Ubuntu are two separate operating systems. They see the same Bluetooth adapter.</p>
<p>If one operating system establishes a new pairing, it can replace the link key stored by the earbuds. The other operating system may still have its old key, which no longer matches.</p>
<p>This explains why simply pairing the earbuds separately in both operating systems is not a reliable solution for classic Bluetooth devices.</p>
<p><strong>The approach:</strong> pair the device in Windows, extract the resulting pairing credentials, and import them into Ubuntu so both operating systems use the same credentials.</p>
<h2>2. Understanding the Bluetooth components</h2>
<p>Before changing anything, it helps to understand the two storage systems involved.</p>
<h3>Windows: the SYSTEM registry hive</h3>
<p>Windows stores Bluetooth pairing information in its SYSTEM registry hive.</p>
<p>For classic Bluetooth, the relevant registry location is:</p>
<pre><code class="language-text">HKEY_LOCAL_MACHINE\SYSTEM\
  CurrentControlSet\Services\BTHPORT\Parameters\Keys
</code></pre>
<p>Under this location, Windows maintains entries associated with the Bluetooth adapter and paired devices.</p>
<p>Conceptually, the structure looks like this:</p>
<pre><code class="language-text">SYSTEM
└── CurrentControlSet
    └── Services
        └── BTHPORT
            └── Parameters
                └── Keys
                    └── &lt;Bluetooth adapter MAC&gt;
                        └── &lt;paired device MAC&gt;
</code></pre>
<p>For the classic Bluetooth device in this experiment, the pairing information was stored as a 16-byte binary Link Key value associated with the device MAC address.</p>
<p>The registry data is protected by Windows permissions. Reading the offline SYSTEM hive from Linux avoids trying to export this protected key through an ordinary Windows registry export.</p>
<h3>Linux: BlueZ storage</h3>
<p>Ubuntu uses BlueZ as its Bluetooth protocol stack.</p>
<p>BlueZ stores persistent Bluetooth information under:</p>
<pre><code class="language-text">/var/lib/bluetooth/
</code></pre>
<p>The directory structure is organised around the local adapter and remote devices:</p>
<pre><code class="language-text">/var/lib/bluetooth/
└── &lt;adapter-mac&gt;/
    ├── settings
    ├── cache/
    └── &lt;device-mac&gt;/
        └── info
</code></pre>
<p>The remote device's <code>info</code> file can contain sections such as:</p>
<pre><code class="language-ini">[General]
Name=Bluetooth Device
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false

[LinkKey]
Key=&lt;REDACTED&gt;
Type=4
PINLength=0
</code></pre>
<p>The <code>Key</code> is the sensitive pairing credential. It must never be published or committed to a repository.</p>
<p>BlueZ's documentation describes the structure of this storage and the fields used for Link Keys and other pairing information.</p>
<h2>3. My test environment</h2>
<p>This is the hardware and software configuration used for the experiment.</p>
<table>
<thead>
<tr>
<th>Component</th>
<th>Configuration</th>
</tr>
</thead>
<tbody><tr>
<td>Laptop</td>
<td>Dell G15 5520</td>
</tr>
<tr>
<td>Operating systems</td>
<td>Windows + Ubuntu 26.04.1 LTS</td>
</tr>
<tr>
<td>Bluetooth stack on Linux</td>
<td>BlueZ 5.85</td>
</tr>
<tr>
<td>Bluetooth adapter</td>
<td>Internal Dell laptop adapter</td>
</tr>
<tr>
<td>Bluetooth device</td>
<td>realme Buds Wireless 5 ANC</td>
</tr>
<tr>
<td>Linux kernel</td>
<td>7.0.0-38-generic</td>
</tr>
<tr>
<td>Desktop environment</td>
<td>GNOME 50.1</td>
</tr>
<tr>
<td>Migration utility</td>
<td>One Pair</td>
</tr>
<tr>
<td>Registry reader</td>
<td>chntpw</td>
</tr>
</tbody></table>
<p>The Bluetooth MAC addresses are intentionally omitted from the published article. They are included as placeholders in the commands so the procedure can be adapted to other machines.</p>
<h2>4. The solution: One Pair</h2>
<img src="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/3f2c2ac8-05a5-4279-8c7d-078da9666510.png" alt="2" style="display:block;margin:0 auto" />

<p>I found <a href="https://github.com/C6S/one-pair">One Pair</a>, a project designed specifically for sharing Bluetooth pairings between Windows and Linux in dual-boot systems.</p>
<p>Its basic workflow is:</p>
<ol>
<li>Read Bluetooth pairing credentials from the Windows registry.</li>
<li>Identify the relevant adapter and paired device.</li>
<li>Extract the appropriate Bluetooth key material.</li>
<li>Convert it into the format expected by BlueZ.</li>
<li>Write the resulting device information into <code>/var/lib/bluetooth/</code>.</li>
</ol>
<p>One Pair supports both classic Bluetooth (BR/EDR) link keys and Bluetooth Low Energy (BLE) pairing material.</p>
<p>For this experiment, the earbuds were identified as a classic Bluetooth BR/EDR device, so the classic Link Key migration path was used.</p>
<h3>Why not manually copy the key?</h3>
<p>It is possible to inspect the Windows registry and manually construct a BlueZ <code>info</code> file.</p>
<p>However, this requires understanding the registry structure, reading binary values correctly, identifying the correct adapter and device, and formatting the result as BlueZ expects.</p>
<p>One Pair automates those steps and provides a dry-run option. That made it a safer starting point than manually editing the Bluetooth database.</p>
<h2>5. Step-by-step implementation</h2>
<p>The following procedure assumes that Windows and Ubuntu are already installed on the same laptop.</p>
<h3>Step 1: Pair the Bluetooth device in Windows</h3>
<p>First, I removed the old pairing from both operating systems so that there would be no uncertainty about which credentials were current.</p>
<p>I then booted into Windows and paired the realme Buds Wireless 5 ANC normally.</p>
<p>At this point:</p>
<ul>
<li>Windows had a fresh pairing.</li>
<li>Ubuntu did not have a new pairing for the earbuds.</li>
<li>The earbuds had not been paired again in Ubuntu.</li>
</ul>
<p>This order matters for classic Bluetooth devices.</p>
<p>One Pair's documentation specifically warns that classic Bluetooth devices should be paired in Windows last before importing the key into Linux. Pairing them in Linux afterward can replace the key stored on the device.</p>
<h3>Step 2: Boot Ubuntu and prepare the Windows partition</h3>
<p>After pairing in Windows, I shut Windows down fully and booted Ubuntu.</p>
<p>I identified the Windows partition:</p>
<pre><code class="language-bash">lsblk -f
</code></pre>
<p>The Windows installation was on an NTFS partition. In my case, it was:</p>
<pre><code class="language-text">/dev/nvme0n1p3
</code></pre>
<p>I mounted it read-only:</p>
<pre><code class="language-bash">sudo mkdir -p /mnt/windows

sudo mount -t ntfs3 -o ro \
  /dev/nvme0n1p3 \
  /mnt/windows
</code></pre>
<p>Verify the mount:</p>
<pre><code class="language-bash">findmnt /mnt/windows
</code></pre>
<p>I also checked that the offline Windows SYSTEM hive was accessible:</p>
<pre><code class="language-bash">test -f /mnt/windows/Windows/System32/config/SYSTEM \
  &amp;&amp; echo "Windows SYSTEM hive found"
</code></pre>
<p>A read-only mount is intentional. We only need to read Windows' registry data; there is no reason to modify the Windows partition.</p>
<h3>Step 3: Install the required tools</h3>
<p>One Pair uses <code>chntpw</code> to read the offline Windows registry hive.</p>
<p>Install the required packages:</p>
<pre><code class="language-bash">sudo apt update
sudo apt install git chntpw
</code></pre>
<p>Clone the repository:</p>
<pre><code class="language-bash">git clone https://github.com/C6S/one-pair.git
cd one-pair
</code></pre>
<p>The script in the repository can be invoked through Bash even if its executable permission is not set:</p>
<pre><code class="language-bash">bash ./import.sh
</code></pre>
<h3>Step 4: Back up the existing Ubuntu Bluetooth database</h3>
<p>Before modifying anything under <code>/var/lib/bluetooth</code>, I created a complete backup.</p>
<pre><code class="language-bash">sudo tar -C /var/lib -czf \
  "$HOME/bluetooth-backup-$(date +%F-%H%M%S).tar.gz" \
  bluetooth
</code></pre>
<p>The archive was initially created by root, so I transferred ownership to my user and restricted its permissions:</p>
<pre><code class="language-bash">sudo chown "$USER":"$(id -gn)" \
  "$HOME"/bluetooth-backup-*.tar.gz

chmod 600 "$HOME"/bluetooth-backup-*.tar.gz
</code></pre>
<p>This backup is important because BlueZ's database contains pairing credentials and other persistent Bluetooth information.</p>
<p>Keep the archive private. It contains sensitive information.</p>
<h3>Step 5: Identify the adapter and device</h3>
<p>Before importing anything, I checked the Bluetooth adapter and the earbuds' MAC address.</p>
<p>The adapter address can be inspected with:</p>
<pre><code class="language-bash">bluetoothctl list
</code></pre>
<p>The device address can be inspected with:</p>
<pre><code class="language-bash">bluetoothctl devices
</code></pre>
<p>For this experiment, I used placeholders below:</p>
<pre><code class="language-text">&lt;ADAPTER_MAC&gt; = your laptop's Bluetooth adapter address
&lt;DEVICE_MAC&gt;  = your earbuds' Bluetooth address
</code></pre>
<p>The adapter address must match the directory used by BlueZ under <code>/var/lib/bluetooth/</code>.</p>
<p>This is particularly important if a system has more than one Bluetooth adapter. One Pair's documentation notes that its default adapter selection uses the first MAC-named directory it finds.</p>
<h3>Step 6: Run a dry run first</h3>
<p>This was the most important safety check.</p>
<p>One Pair supports <code>--dry-run</code>, which previews the information it would write without modifying the Bluetooth database.</p>
<p>I ran:</p>
<pre><code class="language-bash">sudo bash ./import.sh \
  --dry-run \
  --no-restart \
  --no-connect \
  --device &lt;DEVICE_MAC&gt; \
  /mnt/windows
</code></pre>
<p>The arguments mean:</p>
<table>
<thead>
<tr>
<th>Argument</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td><code>--dry-run</code></td>
<td>Preview the changes without writing them</td>
</tr>
<tr>
<td><code>--no-restart</code></td>
<td>Do not restart the Bluetooth service</td>
</tr>
<tr>
<td><code>--no-connect</code></td>
<td>Do not attempt to connect automatically</td>
</tr>
<tr>
<td><code>--device</code></td>
<td>Restrict the import to one Bluetooth device</td>
</tr>
<tr>
<td><code>/mnt/windows</code></td>
<td>Location of the mounted Windows partition</td>
</tr>
</tbody></table>
<p>For my realme earbuds, the dry run identified:</p>
<ul>
<li>The correct local Bluetooth adapter.</li>
<li>The exact remote device.</li>
<li>The Windows classic Bluetooth Link Key.</li>
<li>The expected BlueZ destination file.</li>
</ul>
<p>The preview contained a <code>[LinkKey]</code> section with a key, a key type, and a PIN length.</p>
<p>I deliberately did not publish the key value.</p>
<p>The command also confirmed:</p>
<pre><code class="language-text">dry run: no changes made.
</code></pre>
<p>I did not proceed until the dry run identified the correct adapter and device.</p>
<h3>Step 7: Import the pairing information</h3>
<p>After the dry run succeeded, I ran the same command without <code>--dry-run</code>:</p>
<pre><code class="language-bash">sudo bash ./import.sh \
  --no-restart \
  --no-connect \
  --device &lt;DEVICE_MAC&gt; \
  /mnt/windows
</code></pre>
<p>This imported the Windows pairing information into BlueZ.</p>
<p>I intentionally retained <code>--no-restart</code> and <code>--no-connect</code> so that I could verify the file before restarting the Bluetooth service.</p>
<h3>Step 8: Verify the BlueZ device record</h3>
<p>The generated file is located at:</p>
<pre><code class="language-text">/var/lib/bluetooth/&lt;ADAPTER_MAC&gt;/&lt;DEVICE_MAC&gt;/info
</code></pre>
<p>I inspected its non-secret fields:</p>
<pre><code class="language-bash">sudo grep -E \
  '^\[|^(Name|SupportedTechnologies|Trusted|Blocked|Type|PINLength)=' \
  /var/lib/bluetooth/&lt;ADAPTER_MAC&gt;/&lt;DEVICE_MAC&gt;/info
</code></pre>
<p>This is preferable to printing the entire file because the <code>Key=</code> field contains sensitive material.</p>
<p>I also checked its permissions:</p>
<pre><code class="language-bash">sudo stat -c '%A %U:%G %n' \
  /var/lib/bluetooth/&lt;ADAPTER_MAC&gt;/&lt;DEVICE_MAC&gt;/info
</code></pre>
<p>My generated file had these permissions:</p>
<pre><code class="language-text">-rw------- root:root
</code></pre>
<p>That means only root can read or write the file.</p>
<p>The file contained the expected sections:</p>
<pre><code class="language-ini">[General]
Name=BT Device &lt;DEVICE_ID&gt;
SupportedTechnologies=BR/EDR;
Trusted=true
Blocked=false

[LinkKey]
Key=&lt;REDACTED&gt;
Type=4
PINLength=0
</code></pre>
<p>The name was generic in the imported record. BlueZ can discover additional device information when it connects.</p>
<h3>Step 9: Restart Bluetooth</h3>
<p>Once the record looked correct, I restarted the Bluetooth service:</p>
<pre><code class="language-bash">sudo systemctl restart bluetooth
</code></pre>
<p>At this stage, I could use either the terminal or the GNOME Bluetooth interface.</p>
<p>I chose the graphical interface:</p>
<ol>
<li>Open <strong>Settings → Bluetooth</strong>.</li>
<li>Make sure Bluetooth is enabled.</li>
<li>Turn on the earbuds.</li>
<li>Find the existing device entry.</li>
<li>Click <strong>Connect</strong>.</li>
</ol>
<p>I did not click Forget Device or initiate a fresh pairing.</p>
<p>The earbuds connected successfully.</p>
<p>That was the first confirmation that the imported Windows credentials were accepted by Ubuntu.</p>
<h2>6. The actual test: switching between Windows and Ubuntu</h2>
<p>A successful connection in Ubuntu alone is not enough to prove that dual-boot pairing works.</p>
<p>The important test is whether both operating systems can continue using the same pairing after switching back and forth.</p>
<p>I tested the following sequence:</p>
<table>
<thead>
<tr>
<th>Test</th>
<th>Result</th>
</tr>
</thead>
<tbody><tr>
<td>Pair earbuds in Windows</td>
<td>Successful</td>
</tr>
<tr>
<td>Import Windows credentials into Ubuntu</td>
<td>Successful</td>
</tr>
<tr>
<td>Connect earbuds in Ubuntu</td>
<td>Successful</td>
</tr>
<tr>
<td>Switch to Windows and use the earbuds</td>
<td>Successful</td>
</tr>
<tr>
<td>Switch back to Ubuntu and use the earbuds</td>
<td>Successful</td>
</tr>
</tbody></table>
<p>The earbuds worked across the operating-system switch without requiring another pairing operation.</p>
<p>This was the outcome I wanted.</p>
<p>It demonstrated that, for this particular classic Bluetooth device and adapter, sharing the pairing credentials between the two operating systems solved the repeated-pairing problem.</p>
<img src="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/e52117de-4b94-4d70-bba9-f91b3b29ac00.png" alt="3" style="display:block;margin:0 auto" />

<h2>7. Why the solution works</h2>
<p>The key idea is that the Bluetooth device and the laptop's adapter need to agree on the pairing credentials.</p>
<p>Windows and Ubuntu normally maintain separate copies of those credentials.</p>
<p>One Pair extracts the Windows credentials and places them in the format that BlueZ expects.</p>
<p>The resulting arrangement is:</p>
<pre><code class="language-text">                  Dell G15 5520
                Bluetooth Adapter
                         |
                  Same adapter MAC
                         |
              +----------+----------+
              |                     |
           Windows                Ubuntu
              |                     |
       Windows Registry        BlueZ Database
              |                     |
              +----------+----------+
                         |
                 Same Link Key
                         |
                 realme Buds
</code></pre>
<p>The operating systems still have separate Bluetooth stacks and separate databases. We are not synchronising the operating systems themselves.</p>
<p>We are making the relevant pairing credentials consistent.</p>
<p>BlueZ's documented storage format includes a <code>[LinkKey]</code> section containing the key, key type, and PIN length. One Pair generates that format from the Windows registry.</p>
<h2>8. Important caveats and limitations</h2>
<p>This solution worked for my hardware, but it is important not to generalise the result beyond what was tested.</p>
<h3>Classic Bluetooth and BLE are not identical</h3>
<p>Bluetooth Classic (BR/EDR) and Bluetooth Low Energy use different pairing mechanisms and key material.</p>
<p>One Pair supports both, but the registry fields and BlueZ records differ.</p>
<p>My successful test used the classic BR/EDR Link Key path. It should not be treated as a test of every BLE device or every Bluetooth peripheral.</p>
<h3>Pair Windows first for classic Bluetooth</h3>
<p>For classic Bluetooth devices, the device generally maintains one active link key for a given host identity.</p>
<p>If you pair the device again in Ubuntu, the key stored on the device may change. Windows could then lose its matching key.</p>
<p>If that happens, pair the device in Windows again and re-import the current credentials into Ubuntu.</p>
<h3>The Bluetooth adapter matters</h3>
<p>This method relies on both operating systems using the same physical Bluetooth adapter and adapter address.</p>
<p>If you switch adapters, use a USB Bluetooth dongle in one operating system, or change adapter identities, the same credentials may not work.</p>
<h3>BlueZ storage is sensitive</h3>
<p>Do not:</p>
<ul>
<li>Publish the <code>Key=</code> value.</li>
<li>Upload the raw Windows registry hive.</li>
<li>Commit Bluetooth database backups to GitHub.</li>
<li>Share unredacted <code>.reg</code> exports.</li>
<li>Leave temporary copies of pairing credentials in public folders.</li>
</ul>
<p>Treat the pairing key like a password or other authentication secret.</p>
<h3>Directly editing BlueZ storage is not generally recommended</h3>
<p>BlueZ documentation discourages modifying its storage directly outside the Bluetooth daemon.</p>
<p>That is why I used a purpose-built migration utility rather than manually constructing the record.</p>
<p>Always review a script before running it with <code>sudo</code>, and use its dry-run mode where available.</p>
<h2>9. Troubleshooting</h2>
<h3>The earbuds still ask for pairing</h3>
<p>Check that:</p>
<ul>
<li>You paired the earbuds in Windows after removing the previous pairing.</li>
<li>You imported the current Windows pairing rather than an old registry entry.</li>
<li>You selected the correct Windows partition.</li>
<li>You selected the correct device MAC address.</li>
<li>The imported file is under the correct adapter directory.</li>
</ul>
<p>For classic Bluetooth, pairing in Ubuntu after importing the Windows key can invalidate the shared key.</p>
<h3><code>br-connection-key-missing</code></h3>
<p>One Pair documents this error as a possible symptom of a stale classic Bluetooth key.</p>
<p>The device may have been paired in Linux after the Windows pairing was created, replacing the key stored on the device.</p>
<p>Pair again in Windows and repeat the import.</p>
<h3>The device appears but does not connect</h3>
<p>Check the Bluetooth service:</p>
<pre><code class="language-bash">systemctl status bluetooth
</code></pre>
<p>Inspect the device without exposing its key:</p>
<pre><code class="language-bash">bluetoothctl info &lt;DEVICE_MAC&gt;
</code></pre>
<p>Check the BlueZ record and file permissions as shown earlier.</p>
<p>Do not immediately delete the Bluetooth database or repeatedly pair the device. First establish whether the imported key is current.</p>
<h3>Restore the previous Bluetooth database</h3>
<p>If the import causes problems, use the backup created before the migration.</p>
<p>First identify the exact archive:</p>
<pre><code class="language-bash">ls -lh "$HOME"/bluetooth-backup-*.tar.gz
</code></pre>
<p>Stop Bluetooth:</p>
<pre><code class="language-bash">sudo systemctl stop bluetooth
</code></pre>
<p>Restore the selected backup. Replace the archive name with the exact file you created:</p>
<pre><code class="language-bash">sudo tar -C /var/lib -xzf \
  "$HOME/bluetooth-backup-YYYY-MM-DD-HHMMSS.tar.gz"
</code></pre>
<p>Then restart Bluetooth:</p>
<pre><code class="language-bash">sudo systemctl start bluetooth
</code></pre>
<p>Restoring the backup replaces files with their archived versions, but does not necessarily remove new files that were created after the backup. For a complete rollback, inspect the affected device directory and reconcile it with the backup before proceeding.</p>
<h2>10. Final thoughts</h2>
<p>This was a small but satisfying Linux troubleshooting exercise.</p>
<p>The issue initially looked like an ordinary Bluetooth pairing problem. However, the actual cause was the separation between Windows' and Linux's pairing databases.</p>
<p>Instead of repeatedly pairing the same earbuds, I inspected the Windows registry, understood how BlueZ stores pairing information, and used an existing open-source tool to migrate the credentials.</p>
<p>The final result was simple:</p>
<p><strong>Pair once in Windows. Import the pairing into Ubuntu. Use the same earbuds across both operating systems.</strong></p>
<p>Tested on a Dell G15 5520 running Windows and Ubuntu 26.04.1 LTS, with realme Buds Wireless 5 ANC and BlueZ 5.85.</p>
<p>The successful result is specific to this hardware and pairing configuration, but the underlying approach is useful for understanding and troubleshooting Bluetooth pairing on other dual-boot Linux systems.</p>
<h2>References</h2>
<ul>
<li><a href="https://github.com/C6S/one-pair">One Pair - GitHub repository</a></li>
<li><a href="https://github.com/C6S/one-pair/blob/main/README.md">One Pair - README and usage instructions</a></li>
<li><a href="https://github.com/bluez/bluez/blob/master/doc/settings-storage.txt">BlueZ - Settings Storage documentation</a></li>
<li><a href="https://github.com/bluez/bluez/blob/master/doc/mgmt-protocol.rst">BlueZ - Management API documentation</a></li>
</ul>
<h2>Test environment summary</h2>
<table>
<thead>
<tr>
<th>Item</th>
<th>Tested configuration</th>
</tr>
</thead>
<tbody><tr>
<td>Laptop</td>
<td>Dell G15 5520</td>
</tr>
<tr>
<td>Linux</td>
<td>Ubuntu 26.04.1 LTS</td>
</tr>
<tr>
<td>Bluetooth stack</td>
<td>BlueZ 5.85</td>
</tr>
<tr>
<td>Device</td>
<td>realme Buds Wireless 5 ANC</td>
</tr>
<tr>
<td>Migration utility</td>
<td>One Pair</td>
</tr>
<tr>
<td>Pairing type tested</td>
<td>BR/EDR</td>
</tr>
<tr>
<td>Result</td>
<td>Successful connection across Windows and Ubuntu</td>
</tr>
</tbody></table>
<p><em>This is a record of an actual troubleshooting process. Commands and identifying addresses have been generalised for publication; the real pairing key and private backup files have intentionally been excluded.</em></p>
]]></content:encoded></item><item><title><![CDATA[I Built My Developer Portfolio to Run Inside the Terminal | npx vishalrmahajan]]></title><description><![CDATA[Explore how I built an interactive developer portfolio CLI using Node.js and terminal-kit, published on npm, and accessible with one command.]]></description><link>https://blog.vishalrmahajan.in/a-developer-cli-portfolio-that-lives-inside-your-terminal-npx-vishalrmahajan-12b5518c9976</link><guid isPermaLink="true">https://blog.vishalrmahajan.in/a-developer-cli-portfolio-that-lives-inside-your-terminal-npx-vishalrmahajan-12b5518c9976</guid><category><![CDATA[Node.js]]></category><category><![CDATA[npm]]></category><category><![CDATA[portfolio]]></category><category><![CDATA[terminal]]></category><category><![CDATA[cli]]></category><category><![CDATA[Terminalkit]]></category><dc:creator><![CDATA[Vishal Mahajan]]></dc:creator><pubDate>Sun, 20 Jul 2025 13:55:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753128711017/fe0df948-4242-4c48-bd8a-8265db9b1f7f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most developer portfolios follow a familiar pattern.</p>
<p>You open a website, scroll through an introduction, explore a few projects, look at some skills, and eventually reach a contact section. There is nothing wrong with that approach. It works, and it has become the standard way developers present themselves online.</p>
<p>But I wanted to experiment with something different.</p>
<p>What if my portfolio didn't live inside a browser? What if someone could explore my work without opening a website, simply by running a command in their terminal?</p>
<p>That idea eventually became <code>npx vishalrmahajan</code>, an interactive command-line portfolio built with Node.js.</p>
<p>Instead of presenting information through conventional web pages, the application turns the terminal into a navigable interface with sections, keyboard interactions, clickable links, custom commands, ASCII typography, and animated startup and exit sequences.</p>
<p>You can try it yourself:</p>
<pre><code class="language-bash">npx vishalrmahajan
</code></pre>
<p>GitHub: <a href="https://github.com/vishalrmahajan/npx-vishalrmahajan">https://github.com/vishalrmahajan/npx-vishalrmahajan</a></p>
<p>npm: <a href="https://www.npmjs.com/package/vishalrmahajan">https://www.npmjs.com/package/vishalrmahajan</a></p>
<p>In this article, I'll walk through why I built it, how the application is structured, how its terminal interface works, how commands are processed, and how I made the entire experience available through a single npm command.</p>
<iframe src="https://www.youtube.com/embed/aqoyMsZe2K0?feature=oembed" width="700" height="393"></iframe>

<h2>1. The Idea: A Portfolio That Doesn't Look Like a Portfolio</h2>
<p>I spend a considerable amount of time working in the terminal. Whether it's writing code, managing dependencies, debugging applications, or working with Git, the terminal is an environment I interact with every day.</p>
<p>That made me think: why should a developer portfolio always be a website?</p>
<p>I wanted to create something that felt natural to developers while still being accessible to anyone comfortable running a command.</p>
<p>The idea had a few objectives:</p>
<ul>
<li><strong>A different presentation:</strong> Move away from the conventional portfolio layout.</li>
<li><strong>An interactive experience:</strong> Let visitors navigate and explore rather than just read.</li>
<li><strong>Simple distribution:</strong> Make the portfolio accessible without requiring users to clone a repository.</li>
<li><strong>A developer-oriented interface:</strong> Use the terminal as the actual presentation layer.</li>
<li><strong>A modular foundation:</strong> Keep the application easy to maintain and extend.</li>
</ul>
<p>The result was a CLI application that behaves more like a small interactive environment than a collection of terminal print statements.</p>
<h3>Why a CLI instead of a website?</h3>
<p>A terminal portfolio is not necessarily a replacement for a traditional portfolio website. It serves a different purpose.</p>
<p>A website is useful for visual storytelling, detailed project presentations, images, and broader accessibility.</p>
<p>A CLI portfolio offers a more experimental experience. It is lightweight to launch, familiar to developers, and gives visitors a reason to interact with the application.</p>
<p>I wanted the project to be memorable, not simply another page containing links to my GitHub and LinkedIn profiles.</p>
<h2>2. The User Experience</h2>
<p>The entire application can be launched using:</p>
<pre><code class="language-bash">npx vishalrmahajan
</code></pre>
<p>There is no need to manually clone the repository, install dependencies, or configure the application.</p>
<p>Once launched, the application starts with a loading sequence before entering the interactive terminal interface.</p>
<p>The portfolio is divided into four primary sections:</p>
<h3>Home</h3>
<p>The home section introduces me through an ASCII-styled name banner and displays important contact information.</p>
<p>It includes:</p>
<ul>
<li>Email</li>
<li>Personal website</li>
<li>X</li>
<li>GitHub</li>
<li>LinkedIn</li>
<li>Resume</li>
</ul>
<p>Where supported by the terminal, the links are clickable rather than merely displayed as text.</p>
<h3>Skills</h3>
<p>The skills section organizes technologies into categories:</p>
<ul>
<li>Languages</li>
<li>Front-End</li>
<li>Back-End</li>
<li>Databases</li>
<li>Tools</li>
</ul>
<p>Instead of displaying a long unstructured list, the application renders the categories in a grid.</p>
<h3>Experience</h3>
<p>The experience section presents professional information using bordered cards.</p>
<p>Each card includes the role, company, location, and duration. Company names can also link to their respective websites.</p>
<h3>Projects</h3>
<p>The projects section presents selected projects in a side-by-side card layout.</p>
<p>Each card contains a project name, a short description, and a GitHub link.</p>
<p>The current implementation displays two featured projects, including Nirikshan and the CLI portfolio itself.</p>
<p>The complete project list can also be explored through GitHub.</p>
<h2>3. Technology Stack</h2>
<p>I deliberately kept the stack relatively lightweight. Rather than introducing a large application framework, I used Node.js and libraries designed specifically for terminal applications.</p>
<table>
<thead>
<tr>
<th>Technology</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td>Node.js</td>
<td>Application runtime</td>
</tr>
<tr>
<td>terminal-kit</td>
<td>Terminal rendering, keyboard input and terminal control</td>
</tr>
<tr>
<td>chalk</td>
<td>Text colors and styling</td>
</tr>
<tr>
<td>cfonts</td>
<td>ASCII-style name banner</td>
</tr>
<tr>
<td>terminal-link</td>
<td>Clickable terminal hyperlinks</td>
</tr>
<tr>
<td>open</td>
<td>Launching external websites and applications</td>
</tr>
<tr>
<td>strip-ansi</td>
<td>Measuring plain-text content after removing ANSI styling</td>
</tr>
</tbody></table>
<p>A few of these libraries solve small problems, but together they make it possible to build an interface that feels much more like an application than a traditional CLI script.</p>
<h3>Why terminal-kit?</h3>
<p>The most important dependency is <code>terminal-kit</code>.</p>
<p>A conventional Node.js CLI application often prints output using <code>console.log()</code>. That works well for commands that execute once and terminate.</p>
<p>However, I needed something different.</p>
<p>The application had to:</p>
<ul>
<li>Capture keyboard input continuously.</li>
<li>Move the cursor to specific terminal coordinates.</li>
<li>Clear and redraw parts of the screen.</li>
<li>Respond to terminal resizing.</li>
<li>Manage colors and visual elements.</li>
<li>Maintain an interactive interface.</li>
</ul>
<p><code>terminal-kit</code> provides the terminal-control functionality needed to implement these behaviors.</p>
<p>It is effectively the foundation of the application's user interface.</p>
<h2>4. Application Architecture</h2>
<p>One of the important decisions was to avoid putting the entire application inside a single JavaScript file.</p>
<p>Even though this is a relatively small project, the interface, command handling, content, and startup behavior have different responsibilities.</p>
<p>I separated them into individual modules.</p>
<h3>Project structure</h3>
<p>The core source code is organized approximately as follows:</p>
<pre><code class="language-text">npx-vishalrmahajan/
│
├── index.js
├── data.js
├── loader.js
│
├── terminal/
│   ├── terminal.js
│   └── commands.js
│
├── sections/
│   ├── home.js
│   ├── skills.js
│   ├── experience.js
│   └── projects.js
│
├── package.json
└── README.md
</code></pre>
<p>Each module has a specific responsibility.</p>
<p><code>index.js</code> <strong>- Application entry point</strong></p>
<p>Responsible for initializing the application, registering keyboard events, managing navigation, and rendering the selected section.</p>
<p><code>data.js</code> <strong>- Portfolio data</strong></p>
<p>Contains the name, contact information, colors, about section, skills, experience, and projects.</p>
<p><code>loader.js</code> <strong>- Startup and exit animations</strong></p>
<p>Contains the animated startup and shutdown sequences.</p>
<p><code>terminal/terminal.js</code> <strong>- Terminal engine</strong></p>
<p>Handles terminal input, drawing the navigation bar, rendering the command area, and maintaining command-related state.</p>
<p><code>terminal/commands.js</code> <strong>- Command interpreter</strong></p>
<p>Processes user commands and determines whether to return text or trigger an application action.</p>
<p><code>sections/</code> <strong>- Individual portfolio sections</strong></p>
<p>Each section has its own rendering function.</p>
<p>This separation makes the project easier to maintain. Updating a project description, for example, does not require modifying the terminal rendering engine.</p>
<h2>5. Understanding the Application Lifecycle</h2>
<p>Before looking at individual modules, it helps to understand what happens when someone launches the application.</p>
<p>The execution flow looks like this:</p>
<img src="https://cdn.hashnode.com/uploads/covers/687e92dc46b382b26f74025d/5a530ac9-656d-4821-b177-677cbc6e07bf.png" alt="" style="display:block;margin:0 auto" />

<p>The application entry point imports the terminal functionality and individual section renders:</p>
<pre><code class="language-javascript">import termkit from "terminal-kit";

import {
  initTerminal,
  drawTerminal,
  drawTaskbar,
  handleTerminalInput,
  setSelectedTab,
  getSelectedTab,
} from "./terminal/terminal.js";

import showHome from "./sections/home.js";
import showSkills from "./sections/skills.js";
import showExperience from "./sections/experience.js";
import showProjects from "./sections/projects.js";

import { FULL_NAME } from "./data.js";
import { startupProgress, exitProgress } from "./loader.js";
</code></pre>
<p>The application then initializes itself:</p>
<pre><code class="language-javascript">const term = termkit.terminal;

const tabs = [
  "Home",
  "Skills",
  "Experience",
  "Projects"
];

let selected = 0;

term.clear();

await startupProgress();

initTerminal(tabs, selected);

showSection(tabs[selected]);

term.grabInput(true);
</code></pre>
<p>The startup animation runs first. Once it finishes, the terminal is initialized, the Home section is displayed, and keyboard input is enabled.</p>
<p>This gives the application a clear lifecycle instead of immediately printing portfolio information to the terminal.</p>
<h2>6. Building the Terminal Interface</h2>
<p>A terminal is fundamentally a grid of character positions.</p>
<p>Unlike a browser, where elements are positioned using CSS layouts, terminal applications need to manage cursor positions, available columns, rows, and text width.</p>
<p>That makes layout management an interesting part of the implementation.</p>
<h3>Navigation bar</h3>
<p>The application uses a simple navigation bar at the top.</p>
<p>The currently selected section is highlighted:</p>
<pre><code class="language-javascript">export function drawTaskbar() {
  term.moveTo(1, 1).eraseLine();

  const tabText = tabs
    .map((tab, i) =&gt;
      i === selected
        ? `[ ${tab.toUpperCase()} ]`
        : tab
    )
    .join("   ");

  const xCenter = Math.floor(
    (term.width - tabText.length) / 2
  );

  term.moveTo(xCenter, 1);
  term.magenta(tabText);
}
</code></pre>
<p>The important part is that the navigation is generated from an array of tabs rather than being hardcoded into separate rendering functions.</p>
<p>This makes it easier to add or remove sections.</p>
<h3>Rendering individual sections</h3>
<p>The application uses a <code>showSection()</code> function to decide what should be rendered.</p>
<pre><code class="language-javascript">function showSection(name) {
  term.moveTo(1, 3).eraseDisplayBelow();

  let content;

  switch (name) {
    case "Home":
      content = showHome();
      break;

    case "Skills":
      content = showSkills();
      break;

    case "Experience":
      content = showExperience();
      break;

    case "Projects":
      content = showProjects();
      break;

    default:
      term.red("Unknown section");
      return;
  }

  const lines = content.toString().split("\n");

  const maxContentHeight = term.height - 16;

  const displayLines = lines.slice(0, maxContentHeight);

  displayLines.forEach((line, i) =&gt; {
    term.moveTo(2, 3 + i);
    term(line);
  });

  drawTerminal();
}
</code></pre>
<p>Notice that the individual section functions return strings.</p>
<p>They do not independently control the entire application lifecycle.</p>
<p>The main application decides where the content should appear and when the terminal should be redrawn.</p>
<p>This is a useful separation between content generation and terminal presentation.</p>
<h2>7. Creating Reusable Terminal Components</h2>
<p>I also wanted the portfolio sections to have a consistent visual identity.</p>
<p>Instead of drawing every card separately, I used reusable rendering functions.</p>
<h3>Experience cards</h3>
<p>The experience renderer takes information from <code>EXPERIENCE</code> and builds a bordered card.</p>
<pre><code class="language-javascript">function createExperienceCard(
  exp,
  width,
  terminalWidth
) {
  const leftMargin = Math.floor(
    (terminalWidth - width) / 2
  );

  const margin = " ".repeat(leftMargin);

  const innerWidth = width - 4;

  const lines = [];

  lines.push(
    margin +
    chalk.hex(COLORS.secondary)(
      "╭" + "─".repeat(width - 2) + "╮"
    )
  );

  // Render role and company.

  // Render location and duration.

  lines.push(
    margin +
    chalk.hex(COLORS.secondary)(
      "╰" + "─".repeat(width - 2) + "╯"
    )
  );

  return lines;
}
</code></pre>
<p>The actual implementation also centers the role and company, applies background colors to the heading, and adds a clickable company link when a website is available.</p>
<p>The same concept is used for project cards.</p>
<h3>Skills grid</h3>
<p>The skills section uses a three-column layout.</p>
<p>Each category has a heading and its corresponding items.</p>
<p>The layout is generated from <code>SKILL_GROUPS</code>, which means the renderer doesn't need to know which technologies are being displayed.</p>
<p>For example, adding another skill to the data structure automatically makes it available to the renderer.</p>
<p>This approach keeps content and presentation separate.</p>
<h2>8. Making the Terminal Interactive</h2>
<p>A static terminal display would defeat the purpose of this project.</p>
<p>I wanted visitors to be able to interact with the application using both keyboard navigation and typed commands.</p>
<h3>Keyboard navigation</h3>
<p>The main application listens for keyboard events:</p>
<pre><code class="language-javascript">term.on("key", (name) =&gt; {
  switch (name) {
    case "TAB":
      selected = (selected + 1) % tabs.length;

      setSelectedTab(selected);

      drawTaskbar();

      showSection(tabs[selected]);

      break;

    case "SHIFT_TAB":
      selected =
        (selected - 1 + tabs.length) % tabs.length;

      setSelectedTab(selected);

      drawTaskbar();

      showSection(tabs[selected]);

      break;

    case "ESCAPE":
    case "CTRL_C":
      exitProgress();
      break;

    default:
      handleTerminalInput(name);
      break;
  }
});
</code></pre>
<p>The navigation supports:</p>
<ul>
<li><code>TAB</code> to move forward.</li>
<li><code>SHIFT + TAB</code> to move backward.</li>
<li><code>ESC</code> to exit.</li>
<li><code>CTRL + C</code> to exit.</li>
</ul>
<p>This allows visitors to browse the portfolio without needing to type commands for every action.</p>
<h3>Terminal resizing</h3>
<p>Another important part of a terminal application is handling changes in terminal dimensions.</p>
<p>The application listens for resize events:</p>
<pre><code class="language-javascript">term.on("resize", () =&gt; {
  term.clear();

  drawTaskbar();

  showSection(tabs[getSelectedTab()]);

  drawInstructions();
});
</code></pre>
<p>When the terminal dimensions change, the screen is cleared and the currently selected section is rendered again.</p>
<p>This is important because terminal applications cannot assume that users will always launch them in a window of identical dimensions.</p>
<h2>9. Building a Custom Command Interpreter</h2>
<p>This is one of my favorite parts of the project.</p>
<p>I wanted the terminal to feel like a small command environment where visitors could interact with my portfolio through familiar commands.</p>
<p>The command interpreter lives in <code>commands.js</code>.</p>
<p>It accepts the input, normalizes it, separates the command from its arguments, and determines what should happen next.</p>
<p>The core implementation uses a switch statement:</p>
<pre><code class="language-javascript">export function processCommand(command) {
  const cmd = command.trim().toLowerCase();

  const parts = cmd.split(" ");

  switch (parts[0]) {
    case "hello":
    case "hi":
      return `Hello, I'm ${FULL_NAME}.`;

    case "about":
    case "whoami":
      return getWhoami();

    case "help":
      return getHelp();

    case "skills":
      return {
        action: "changeTab",
        tab: "Skills"
      };

    case "experience":
    case "exp":
      return {
        action: "changeTab",
        tab: "Experience"
      };

    case "projects":
    case "proj":
      return {
        action: "changeTab",
        tab: "Projects"
      };

    case "home":
      return {
        action: "changeTab",
        tab: "Home"
      };

    case "clear":
    case "cls":
      return {
        action: "clear"
      };

    case "open":
      return handleOpen(parts[1]);

    default:
      return `Command not found: ${cmd}`;
  }
}
</code></pre>
<p>The application supports commands such as:</p>
<pre><code class="language-bash">help
whoami
about
skills
experience
exp
projects
proj
home
open github
open linkedin
open resume
open x
chat
clear
exit
</code></pre>
<p>It also supports aliases such as <code>hi</code>, <code>cls</code>, and <code>quit</code>.</p>
<h3>Why return actions instead of directly rendering everything?</h3>
<p>One interesting design decision is that the command interpreter can return structured objects.</p>
<p>For example:</p>
<pre><code class="language-javascript">{
  action: "changeTab",
  tab: "Projects"
}
</code></pre>
<p>The terminal engine receives this object and decides how to execute the action.</p>
<pre><code class="language-javascript">if (typeof result === "object" &amp;&amp; result.action) {
  switch (result.action) {
    case "changeTab":
      const idx = tabs.indexOf(result.tab);

      if (idx &gt;= 0) {
        selected = idx;

        drawTaskbar();

        global.showSection(result.tab);
      }

      break;
  }
}
</code></pre>
<p>This separates the responsibility of understanding a command from the responsibility of changing the application state.</p>
<p>The command interpreter doesn't need to know how the terminal screen is drawn.</p>
<p>That separation also makes it easier to introduce additional commands later.</p>
<h2>10. Opening External Links from the Terminal</h2>
<p>A portfolio is only useful if visitors can actually reach the projects and profiles being presented.</p>
<p>For this, I used two libraries:</p>
<ul>
<li><code>terminal-link</code> for clickable links in supported terminal environments.</li>
<li><code>open</code> for launching websites in the default browser.</li>
</ul>
<p>For example, the <code>open github</code> command launches the GitHub profile:</p>
<pre><code class="language-javascript">case "github":
  open(`https://github.com/${CONTACTS.github}`);

  return "Opening GitHub profile in browser...";
</code></pre>
<p>The same approach is used for LinkedIn, X and the resume.</p>
<p>There is also a <code>chat</code> command that opens Telegram.</p>
<p>This is a small detail, but it changes the experience significantly.</p>
<p>Instead of copying a URL from the terminal and pasting it into a browser, visitors can interact with the links directly.</p>
<h2>11. The Startup and Exit Experience</h2>
<p>I didn't want the application to immediately display its contents after execution.</p>
<p>I added a small startup sequence using <code>terminal-kit</code>.</p>
<p>The startup animation displays a series of messages:</p>
<pre><code class="language-javascript">const steps = [
  "Initializing portfolio...",
  "Loading terminal interface...",
  "Setting up navigation...",
  "Loading sections...",
  "Ready to launch!"
];
</code></pre>
<p>A progress bar is generated based on the current step:</p>
<pre><code class="language-javascript">const filled = Math.floor(
  ((i + 1) / steps.length) * barWidth
);

const bar =
  "█".repeat(filled) +
  "░".repeat(barWidth - filled);
</code></pre>
<p>The percentage is also updated as the animation progresses.</p>
<p>The exit sequence follows a similar approach and displays a shutdown animation before terminating the application.</p>
<p>These animations are primarily presentation elements rather than actual loading indicators. Their purpose is to make the beginning and end of the experience feel intentional.</p>
<h2>12. Making It Available Through npm</h2>
<p>Building the application was only half the work.</p>
<p>I also wanted anyone to be able to run it without cloning the repository.</p>
<p>This is where npm distribution becomes useful.</p>
<p>The package configuration contains:</p>
<pre><code class="language-json">{
  "name": "vishalrmahajan",
  "version": "1.1.3",
  "description": "CLI Portfolio for VishalRMahajan",
  "main": "index.js",
  "bin": {
    "vishalrmahajan": "./index.js"
  },
  "type": "module"
}
</code></pre>
<p>The important property here is <code>bin</code>.</p>
<pre><code class="language-json">"bin": {
  "vishalrmahajan": "./index.js"
}
</code></pre>
<p>It tells npm that the <code>index.js</code> file should be exposed as an executable command named <code>vishalrmahajan</code>.</p>
<p>The entry point also begins with a shebang:</p>
<pre><code class="language-javascript">#!/usr/bin/env node
</code></pre>
<p>This allows compatible environments to execute the file using Node.js.</p>
<p>Once published, users can launch the package using:</p>
<pre><code class="language-bash">npx vishalrmahajan
</code></pre>
<p>Alternatively, they can install it globally:</p>
<pre><code class="language-bash">npm install -g vishalrmahajan
</code></pre>
<p>And then run:</p>
<pre><code class="language-bash">vishalrmahajan
</code></pre>
<p>This is one of the most satisfying parts of the project.</p>
<p>A collection of JavaScript modules becomes something that another developer can launch with a single command.</p>
<h2>13. What I Learned While Building It</h2>
<p>This project started as an experiment in presenting a portfolio differently, but it also gave me an opportunity to think about application development outside the browser.</p>
<p>Some of the important takeaways were:</p>
<p><strong>1. Terminal applications have their own UI engineering challenges.</strong></p>
<p>Building an interface inside a terminal requires thinking about cursor positioning, character width, terminal dimensions, redraws, and keyboard events.</p>
<p>There is no browser layout engine doing this work automatically.</p>
<p><strong>2. Separation of concerns matters even in small projects.</strong></p>
<p>Separating the terminal engine, command interpreter, content, and section renderers made the application easier to reason about.</p>
<p><strong>3. Interaction makes a portfolio more memorable.</strong></p>
<p>Visitors are not just reading information. They are navigating an environment and discovering different parts of the portfolio.</p>
<p><strong>4. Distribution is part of the product.</strong></p>
<p>Making the application available through npm dramatically reduces the effort required to try it.</p>
<p>The experience starts with a single command, which is exactly what I wanted.</p>
<p><strong>5. Small design details make a difference.</strong></p>
<p>The loading sequence, highlighted navigation, clickable links, and consistent card styling help the application feel like a cohesive product.</p>
<h2>14. Limitations and What's Next?</h2>
<p>The current version is a working foundation, but there is still room to improve it.</p>
<p>Some improvements I would like to explore include:</p>
<ul>
<li>Better responsive layouts for narrow terminal windows.</li>
<li>More robust text wrapping and Unicode width handling.</li>
<li>Persistent and scrollable command output.</li>
<li>Command autocomplete and suggestions.</li>
<li>Detailed project views with technology stacks and descriptions.</li>
<li>More flexible theme customization.</li>
<li>Automated tests and better runtime compatibility checks.</li>
</ul>
<p>I also want to explore ways of making the portfolio content easier to update without having to modify rendering logic.</p>
<p>The objective isn't to turn this into a massive terminal framework. I want to preserve what makes the project interesting while improving its usability and reliability.</p>
<h2>15. Try It Yourself</h2>
<p>If you're curious about the experience, you don't need to read through the source code first.</p>
<p>Just open a terminal and run:</p>
<pre><code class="language-bash">npx vishalrmahajan
</code></pre>
<p>You can also explore the implementation:</p>
<ul>
<li><strong>GitHub repository:</strong> <a href="https://github.com/vishalrmahajan/npx-vishalrmahajan">https://github.com/vishalrmahajan/npx-vishalrmahajan</a></li>
<li><strong>npm package:</strong> <a href="https://www.npmjs.com/package/vishalrmahajan">https://www.npmjs.com/package/vishalrmahajan</a></li>
<li><strong>Personal website:</strong> <a href="https://vishalrmahajan.in">https://vishalrmahajan.in</a></li>
<li><strong>LinkedIn:</strong> <a href="https://linkedin.com/in/vishalrmahajan">https://linkedin.com/in/vishalrmahajan</a></li>
</ul>
<p>If you want to build something similar, feel free to explore the repository and experiment with the implementation.</p>
<h2>Conclusion</h2>
<p><code>npx vishalrmahajan</code> started with a simple question: does a developer portfolio always need to be a website?</p>
<p>The answer, at least for this experiment, was no.</p>
<p>Building it gave me the opportunity to combine Node.js, terminal rendering, keyboard interactions, command processing, modular architecture, and npm distribution into one small application.</p>
<p>More importantly, it reminded me that the way we present our work can be just as interesting as the work itself.</p>
<p>A portfolio doesn't always have to be something people scroll through.</p>
<p>Sometimes, it can be something they execute.</p>
<p><strong>One command. One terminal. A different way to explore a developer's work.</strong></p>
<p>Happy hacking! 🚀</p>
]]></content:encoded></item></channel></rss>