Some Bits: Nelson's log

4 posts in August 2026

Being Claude’s agent

I’ve been working on a complex project where I am the agent following instructions and running commands while Claude is the planner giving high order instructions. It’s kind of fun, an inversion of the usual coding agent work pattern.

(An aside: no one can define what an “agent” is. Not even me, a 1990s PhD student in the Software Agents Group at the MIT Media Lab. But one definition is “agents are software that can do things to the outside world”. Agents edit files, or push to GitHub, or pwn a competitor’s AI company. It’s the agency that makes an agent an agent. By this definition I am the agent in my scenario.)

The project I’m working on is updating my homelab / selfhosted services on Proxmox. Mostly adding a new reverse proxy to give me better access to things. This boils down to creating and configuring a bunch of little Linux containers (caddy, authelia, homepage, ntfy, etc).

I don’t really now how to do all this, so I got Claude Opus to come up with a design that I reviewed. But I didn’t trust Claude Code to implement it. And I wanted to understand how it all worked. So I had Claude write up a very verbose tasklist for me. For the past few days I’ve been dutifully following it. I’m very slow, it’s taken me ~4 hours of actual work when Claude Code would have done it in 10 minutes. But I do understand what it’s doing.

Part of what’s been fun is duplicating some of the way software agents use scratch files as memory. I have a Claude Project with several chat sessions and some text files Claude created keeping track of state. The project has like 15 tasks, each with 3-5 subtasks, and I’ve totally lost the plot. But I trust Claude to keep track of it and every once in awhile I just tell it “ok I did task 13.3. what’s next and what do I do?”

When I work with AIs I am trying to use them as partners for thinking. Most of my interactions with AI are back-and-forth, with me reviewing what its saying and using the AI as a source of ideas and things to consider. I don’t much trust an AI agent to go off and do a complex task for me, at least not one whose result I can’t easily verify. This interactive session where I do the work feels better to me.

One problem is Claude is a never-satisfied taskmaster, it keeps adding things to a giant “backlog” new task list. This is a problem inherent with how these AIs are prompted, it keeps coming up with more things to think about. I feel a bit like Sisyphus. But Claude is pretty good about accepting when I tell it “no, I’m not doing that”.

Linux gaming: GPU overview

I’ve been installing Linux on whatever hardware I happen to have. It’s worked OK on various video cards. But there’s big differences. Most of this post is from the point of view of gaming (Windows games with Proton) but some AI stuff too. No deep expertise here, but I’ve had to learn this all recently and am sharing here.

AMD

AMD GPUs are the best supported in Linux. In general they just work. There’s a reasonable kernel driver built right into the kernel, fringe side features are better supported, and the Mesa user space stuff all does its job well in providing graphics APIs like Vulkan. Valve has invested an enormous amount into supporting AMD cards well in Linux and it shows. Next time I buy a video card, it will be AMD.

The one caveat is AI. Inference does work on AMD, ROCm is a real thing that really works. But there’s a sense the performance isn’t quite as good as with NVidia. I haven’t really tested it carefully.

Intel Arc

These are rumored to work reasonably well for gaming on Linux but they are still rare cards. I have no experience with them. The kernel drivers are part of the regular Linux kernel. Not sure about AI performance.

Nvidia

Oof. This is what I’m saddled with for the high performance cards I have. And the situation is not great. It does all work, and works reasonably well, but it’s such a kludge. I’m grateful to distros like Bazzite or Nobara or CachyOS that take the difficulty out of getting the drivers working. Arch’s docs are helpful info.

The problem is that historically Nvidia’s drivers have been closed source. But they have to run in the kernel. Now they have a more open source driver but only the kernel parts are open source, there’s still a lot of closed user space stuff providing higher level APIs (instead of using Mesa).

So even now there’s some insane thing where you are compiling drivers from source code you get from Nvidia when you install a new Linux kernel. And the kernel has to be signed to boot in Secure Boot, which just makes it more complex. It’s a mess.

There’s at least four flavors of Nvidia GPU driver.

The good ones come from Nvidia. They’re proprietary, but they have good performance. And they do work.

  • The “open” Nvidia drivers. This is the best option and works on cards starting with the 16xx cards and newer (ie: around 2018, Turing architecture and beyond). This driver is under active development by Nvidia, the latest 610 release recently came out. The kernel code is real open source but is only useful in pairing with a bunch of closed user space code.
  • The legacy proprietary Nvidia drivers. These are slowly on the way out but are the only thing that supports older cards like my 1080. I believe these drivers are still supported and getting updates but only limited ones. I think 580 is the last version that will be released?

The bad ones are fully open source and from third parties. They’re not really bad, it’s amazing work, but it’s a lot of reverse engineering and extra effort and their performance is not up to the closed ones.

  • Nouveau with NVK is the main open source driver. Linux systems will install this because it’s easier and license-friendly. But the performance is not great.
  • Nova is a new project to provide a new Nvidia driver in Rust. It’s very new and I think not ready for regular use.

AI inference works great on Nvidia, they pioneered most of the work and are still the leaders in Linux AI.

Rii K22 keyboard reset for Linux

I bought a cheap-but-nice wireless keyboard for occasional use. It works great in the system BIOS (with 2.4GHz) and Windows, but not in Linux. It’d connect but not let me type. Whether connected via 2.4Ghz or Bluetooth.

Turns out this is a known problem with a workaround.

Apparently in this state the keyboard is basically working but somehow the driver didn’t get initialized right and so keyboard and mouse events don’t come through. The workaround is to unbind and rebind the HID just after it’s plugged in using commands like echo 1-2.1.2:1.0 > /sys/bus/usb/drivers/usbhid/bind

I tried a scattershot version of this and it worked once. The permanent fix is to add something to udev that does the unbind/rebind trick when it detects the device is activated. Yuck!

Full details at https://forums.raspberrypi.com/viewtopic.php?t=397618

Linux gaming: switching video and sound

I use my Linux box with a long cable to play games on my TV. When I plug in the TV I want to change resolutions and change sound output devices for the TV. (The display is mirrored from my desktop). This is the kind of thing I’d only do manually in Windows but in Linux it’s reasonable to automate it. Particularly with an AI doing the hard work.

The switch script

Switching boils down to using kscreen-doctor to set the video mode and pactl to change the audio device. I’m using this script manually and it works great.

#!/bin/bash
# Description: Toggle display resolution and audio output between Desktop and TV modes.
# Safe to run multiple times consecutively.

# ================================
# Configuration Variables
# ================================
DISPLAY_NAME="DP-3"

# Desktop Settings
DESKTOP_RES="6016x3384@60"
DESKTOP_CARD="alsa_card.pci-0000_0b_00.4"
DESKTOP_PROFILE="output:analog-stereo"
DESKTOP_SINK="alsa_output.pci-0000_0b_00.4.analog-stereo"

# TV Settings
TV_RES="3840x2160@60"
TV_CARD="alsa_card.pci-0000_09_00.1"
TV_PROFILE="output:hdmi-surround-extra1"
TV_SINK="alsa_output.pci-0000_09_00.1.hdmi-surround-extra1"

# ================================
# Helper Functions
# ================================
switch_audio() {
    local card="$1"
    local profile="$2"
    local sink="$3"

    # 1. Set Card Profile
    pactl set-card-profile "$card" "$profile" 2>/dev/null

    # 2. Set Default Sink
    pactl set-default-sink "$sink" 2>/dev/null

    # 3. Move active audio streams safely
    pactl list short sink-inputs | awk '{print $1}' | while read -r stream; do
        if [ -n "$stream" ]; then
            pactl move-sink-input "$stream" "$sink" 2>/dev/null
        fi
    done
}

# ================================
# Main Execution
# ================================
MODE="${1:-desktop}"

if [ "$MODE" = "tv" ]; then
    echo "📺 Switching to TV Mode..."
    
    # Switch Display to 2160p
    kscreen-doctor "output.${DISPLAY_NAME}.mode.${TV_RES}"
    
    # Switch Audio to NVIDIA 5.1 Surround
    switch_audio "$TV_CARD" "$TV_PROFILE" "$TV_SINK"

else
    echo "🖥️  Switching to Desktop Mode..."
    
    # Switch Display to 6K
    kscreen-doctor "output.${DISPLAY_NAME}.mode.${DESKTOP_RES}"
    
    # Switch Audio to Starship/Matisse Stereo
    switch_audio "$DESKTOP_CARD" "$DESKTOP_PROFILE" "$DESKTOP_SINK"

fi

echo "Done!"

Switching automatically

I haven’t tried this yet, but Gemini has a reasonable plan for making this happen automatically when I plug in the cable. It boils down to running a user systemd service to run udevadm monitor to get notified when the cable is plugged in.

#!/bin/bash
# Description: Auto-detects HDMI hotplug events and calls switch_mode.sh

# Path to your switch script (adjust if located elsewhere)
SWITCH_SCRIPT="$HOME/bin/switch_mode.sh"

# Automatically find the first HDMI connector status path
HDMI_STATUS_FILE=$(ls /sys/class/drm/card*-HDMI-*/status 2>/dev/null | head -n 1)

if [ -z "$HDMI_STATUS_FILE" ]; then
    echo "Error: No HDMI port found in /sys/class/drm/"
    exit 1
fi

echo "Monitoring HDMI port: $HDMI_STATUS_FILE"

check_and_switch() {
    STATUS=$(cat "$HDMI_STATUS_FILE" 2>/dev/null)
    if [ "$STATUS" = "connected" ]; then
        echo "HDMI Connected -> Switching to TV"
        "$SWITCH_SCRIPT" tv
    else
        echo "HDMI Disconnected -> Switching to Desktop"
        "$SWITCH_SCRIPT" desktop
    fi
}

# 1. Run check immediately when the script starts
check_and_switch

# 2. Listen for DRM kernel display events in real time (no root required)
udevadm monitor --subsystem-match=drm | while read -r line; do
    if echo "$line" | grep -q "change"; then
        # Brief pause to let the hardware settle
        sleep 1
        check_and_switch
    fi
done
[Unit]
Description=HDMI Hotplug Display and Audio Switcher
After=graphical-session.target

[Service]
Type=simple
ExecStart=%h/bin/tv_auto_switch.sh
Restart=always
RestartSec=3

[Install]
WantedBy=graphical-session.target

More switching

I didn’t actually set it up but I’m pretty sure udevadm monitor will work as a way to know when an HDMI cable is plugged in to activate the switch. But I realized I’d rather leave the thing plugged in all the time and only switch modes on my Linux box when the TV receiver switches to its video input. I tried for awhile and couldn’t make it work. An AMD video card might.

Some TVs make it look like you basically disconnected the cable when you switch away from that input. They turn off the HDMI hot plug signal and stop sending EDID. My TV does not do this, on the Linux side it looks like it’s always on.

The TV should be sending HDMI-CEC commands down the wire to notify the device when it’s selected as input. In Linux those should be available on /dev/cec0 or the like. Unfortunately the NVidia graphics drivers just don’t support this. Intel and AMD supposedly do. Yet another way NVidia’s Linux support falls short.

I finally just put a button to invoke my script on the KDE taskbar so it’s very easy to switch modes.

Yay for AI

I have the skills to figure scripts out like this myself. It would take me ~2 hours to research and write and debug this script. Or it takes me 10 minutes with an AI. I never would have bothered without. My expertise is still important: I’m asking the questions of the AI the right way and I can review the suggestions to see if they make sense. But the AI is definitely great at this kind of one-off hack.