Ever wondered whether htop could be used to render the graphics of cult video games? I know I have. In order to quench our curiosity and for your viewing pleasure, I created doom-htop.
The main doom process forks and creates as many process as there are lines in the ascii converted image, and then creates a shared memory segment with every single one of them. The main process copies each line in the image to the matching process's memory segment, and each child-process copies from its segment and writes over its argv[0]. That's it, really. Originally I wanted to do it with processes sorted by CPU usage, and create a process that consumes a specific CPU percentage, but that turned out to be pretty hard. Then I though about using linux's nice, but as a user you're only allowed 19 possible values, and I wanted better graphics. Eventually I stumbled upon the idea of using virtual memory allocation, which as I said before, as pretty specific per process. I noticed that even when all the forked processes allocate exactly the same amount of memory, htop shows the frame in the right order. I believe that happens because maybe in case of equality the processes are then sorted by time of creation? This works on my system (and is actually a little better, because that way there is less space in which another process could "get into the frame"), but I wasn't sure how it would work on other people's systems and didn't want to take the chance. This also means that I could have probably just given all the processes a unique nice value, but whatever. Anyways, then I created a simple keylogger that works by opening the keyboard's device. This way the game is always playing in the background regardless of whether htop is open or not, which I think is neat.