Claude Code Fixed My Screensaving
2025-11-15 23:27:41 PST
Bart Massey 2025-11-15
This is a long tale, so buckle in. The ending is pretty surprising.
I'm running Debian Linux with XFCE4 at home. My monitor setup is pretty dank.
I saved a lot of money by being given a 42.5" LG 4K TV (43UK6200PUA) that I use as my primary screen: it reports its size in EDID totally incorrectly, and turns off after long blanking times, but is otherwise a great screen.
My secondary screen is a smaller 31.5" ASUS 4K computer monitor (VP327Q) that I use for screensharing and general stuff.
I have the primary screen scaled in display settings to 0.75×, so that the pixel sizes match up well. With proper monitor vertical alignment, this makes window moves across monitors pretty seamless.
I have GDK HiDPI turned to 2x so that applications are at usable sizes on these displays.
Screen blanking, saving and power management has never gone well with my setup. I prefer to run without a screen saver, but need one here to keep the TV on if I want that — otherwise I'll have to hit the TV's power button every time I want to use the display after a longish absence. Occasionally I'll have to completely repower the TV.
In the summer, I really want the TV and monitor to power off on idle, to save heat. (My previous monitor had an enormous heat out, making this more critical.) In the winter, I'm fine keeping them on, but do want to prevent the tiny chance of screen burn-in even on LCD screens.
(Right now there's some bug that keeps X11 from coming up properly at all after a reboot with my NVIDIA card unless I power off the ASUS monitor before boot. I need to fix that someday, but this is not that day.)
I finally got in the hopeless state where in the middle of a vidchat conversation (usually after about ten minutes) my screens would blank and my speaker (I'm using the TV speaker) would cut off. That's… bad.
I fiddled around a lot with various settings to try to clean this up. Finally it became urgent to get it right. As a "professional" I spend a lot of my time on vidchat doing "important" things. Can't be dealing with this.
Yesterday I had an inspiration. Claude Code can poke around my entire system and make changes. What if I used CC to fix my screen timeout issues?
Good old CC said "sure!" like it always does and started poking around my system. It read a bunch of logs and config files, some of which I didn't know were there, started and stopped a bunch of programs, etc.
A number of discoveries and fixes followed:
I had
xscreensaverenabled, but not installed.Various
xfce4-screensaverandxfce4-power-managersettings were wrong, but not apparently fixable through the XFCE4 settings UI — had to edit textfiles or run "special" commands.xset sgives X server "screen saver" settings that I had forgotten existed.
After banging around for a while, it looked like things would be OK. CC had edited enough stuff that the screensaver and power management were in good shape. My displays stayed on for a long time with no human input. It looked like the screensaver would kick in after 2.5 hours. Life was good. I went to bed.
In the morning, I woke up to find the displays still on, but showing content instead of screensaving. This was progress, but I still wanted to find and fix the core problems.
I fired up CC and started again. I reported my symptom, and CC found more messed up stuff. Ultimately we got to the situation where screensaving started as expected on the ASUS…
On the ASUS. The TV was showing a black screen.
Comedy ensued. A bunch of banging around with things got me to the point where I could't get my cursor theme back. Then it magically fixed itself just as I was finally about to restart X. (That's right. In two days of fiddling with delicate stuff, CC never got me in such bad shape that I needed to restart X. Impressive.)
CC turned on a bunch of debugging and watched some logs and searched
the interwebs, and eventually concluded it was an xfwm4
compositor issue. We tried switching to picom, which seemed
to work, and CC was happy. (My X11 guru friend when I talked to him
about this: "Why do you need a compositor anyway? I never use one." He's
not wrong.)
I wasn't happy. I wanted to fix the compositor bug. I had CC clone
the xfwm4 source code and look around some more. It quickly
(!) zeroed in on a particular few lines of code that did a comparison of
the TV screen size as calculated by Gdk with the screen size as reported
by XRandR. These differed by one pixel, because of rounding of the Gdk
calculation due to my Hidpi 2× setup. Odd vs even. This caused
xfwm4 to report that the fullscreen screensaver window was
obscured, which confused xfce4-screensaver, which refused
to run, since xfce4-screensaver's "don't run screensaver on
fullscreen windows". Or somesuch. I may have the details wrong; check
for yourself.
CC's suggested fix was to allow a "tolerance" of 1 pixel when comparing things. That was a kludge and I told it so. Once we tested that the kludge worked, CC proceeded to properly fix the problem, by avoiding rounding and instead querying XRandR for proper information. Fix complete, CC wrote an issue report and PR and I reviewed them and pushed them to XFCE4's Gitlab.
I found this whole thing pretty remarkable, to be honest. It was probably five or six hours from start to finish. I hand-edited zero files, debugged and fixed zero code. CC did the job by itself. I did make a couple of suggestions, ask a couple of leading questions, and report what I was seeing several times. That was it.
As someone who has been involved with X11 and Linux almost since their respective inceptions, I would estimate that it would have taken me something like a week of hard work to track this down — except I would have given up way earlier. This was a deep and subtle bug, with no direct reports in the wild that we could find. It was pretty hairy. Claude Code just went there and did the thing.
CC has some issues. Its "hooks" safety system is way over-conservative, asking constant permission for trivial things. I would have run in a sandbox with hooks disabled, but I needed to be on my real computer to work on this. I ended up with a bit of "allow" fatigue.
CC runs out of context memory pretty frequently, and has to save a summary of the context, restart, and reload the context to continue. The process is pretty transparent, and I did not see major issues across these events, but it's a thing.
CC is slower than you think it is. Time flies by as it puts pacifiers up and thunks for long spans. My X11 human friend would have worked much faster.
In the end, though, I am more of a CC stan than I started out as. This thing is powerful, and I'm glad I can afford the medium-priced account to be able to use it pretty freely. Turns out CC is great for system tasks, and I have plenty to feed it.
I've posted a session transcript (see an earlier blog post) for your perusal. Enjoy.