💾 Archived View for pixeldreams.tokyo › technomancy › i-made-all-ur-capsules-pink.gmi captured on 2024-07-08 at 23:28:41. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

i made all your gemini capsules pink

june 18, 2021

hello gemini

a few days ago when i started using gemini, i asked someone to recommend me a client that was compatible with my system, so they introduced me to lagrange. lagrange is a cute gui client for gemini but it also supports gopher!

i was originally hoping for a tui client but lagrange is actually very comfortable to use on my laptop! it even supports color for gemini capsules!

sad yellow kyo

i was asking on irc how i could choose colors for my site and to my dismay colors are not a part of the gemini protocol!

what lagrange really does is support eleven color schemes and assign one to every capsule based on things like the url. my capsule got an ugly yellow theme, all because of my name.

i had to do something! why were others getting pretty colors like pink or purple while i was stuck with this awful yellow! i can't change everyone's lagrange client, but i must be able to change mine.

source code

since i'm using openbsd, building lagrange is easy through the ports system. usually i just run make with no arguments to build everything automatically, but this time i let it download the source and apply the port patches for me and pause before actually building anything.

then i dug into the source code. it took a bit of time looking around, but i finally found a promising looking function called setThemeSeed_GmDocument() in gmdocument.c. a little scrolling and i found an array of themes, and a variable called 'primIndex'.

thankfully each theme had a comment telling me what colors it actually had, and i quickly found the pink theme to be index 11, so i hardcoded that value into primIndex!

patch file

applying this patch and recompiling makes every gemini capsule a warm fuzzy pink~☆

$OpenBSD$

Index: src/gmdocument.c
--- src/gmdocument.c.orig
+++ src/gmdocument.c
@@ -1181,7 +1181,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBl
             { 8, 9 },  /* violet */
             { 7, 8 },  /* pink */
         };
-        const size_t primIndex = d->themeSeed ? (d->themeSeed & 0xff) % iElemCount(hues) : 2;
+        const size_t primIndex = 11; //d->themeSeed ? (d->themeSeed & 0xff) % iElemCount(hues) : 2;

         const int   altIndex[2] = { (d->themeSeed & 0x4) != 0, (d->themeSeed & 0x40) != 0 };
         const float altHue      = hues[d->themeSeed ? altHues[primIndex].index[altIndex[0]] : 8];