Pages

Wednesday, June 22, 2022

Dark theme for kdiff3

I was working in the evening, and everything on my Mac was in dark mode but kdiff3.
 
Some of that was due to macOS changing theme when it's late, so you could argue kdiff3, an old enough app that I didn't figure would or should have auto-theme detection for macOS, was right "half the time", and the bigger half [sic] at that, the half during working hours.
 
Still, I caught myself saying, "If it had a dark mode for kdiff3, I'd use it all the time over none."
 
Oh yeah? Turns out that, though it's not in settings in any super-accessible way, after a little googling, kdiff3 does, in fact, have dark mode.
 
You just edit your .kdiff3rc file with custom colors. Of course, right?
 
But how did I learn that? And how could I figure out which colors work together?
 
If you just want one simple, competent dark theme, the answers to those questions are easy to find.
 

Enter Dracula:

It turns out there's a project with an interesting-ish backstory churning out one dark theme for every app that can take them: Dracula, at the very original draculatheme.com.
 
 
  • Replace color lines from your ~/.kdiff3rc (ex on win: C:\Users\<name>\.kdiff3rc) file with the ones from dracula theme's .kdiff3rc
  • Restart Kdiff3
  • Boom! It's working
That's pretty cool. I like the attitude: Hey, here's the minimum you need to play with a dark theme -- dark theme table stakes, if you're into that whole Gruber vernacular -- and here it is for as many apps as possible. A perfect mvp.
 
Though .kdiff3rc files are kind of a pain. The values you want to change are these:
 
FgColor=248,248,242
BgColor=40,42,54
ColorA=139,233,253
ColorB=80,250,123
ColorC=189,147,249
ColorForConflict=255,85,85
CurrentRangeBgColor=68,71,90
CurrentRangeDiffBgColor=98,114,164
DiffBgColor=98,114,164
ManualAlignmentRangeColor=255,184,108
MidAgeFileColor=255,184,108
MissingFileColor=40,42,54
NewestFileColor=80,250,123
OldestFileColor=255,85,85
 
And those aren't necessarily (aka, "Almost certainly aren't") grouped together in your (apparently alphabetized by default?) .kdiff3rc.
 
I'll put a macOS .kdiff3rc whose only differences from the default .kdiff3rc file are Dracula theme changes up on github here:
 
 
Looks like kdiff3 resaves your rc file when it closes and re-alphabatizes, which is an interesting choice. Three cheers for conformance, I guess. Usually a good thing.
 
It's not like it's perfect. After setting colors for the text areas, kdiff3's chrome is still very... chromey. Very heavy toolbars and footer. But it's an old (gtk?) app, so I'm not complaining. 
 
I now have a fully competent dark theme for an old app nobody with any sense of the state of programming tools would expect to have quite this easily.