fastfetch + lain gifs for my Hyprland setup.
The original zsh script worked fine, but I wanted to eliminate shell overhead and take advantage of the fact that fastfetch and GIF selection can run in parallel..
- Immediate fork — launches
fastfetchin the background, redirecting its output to a tmpfile, without waiting. - In parallel — reads
~/.gif-indexand picks a random GIF with its precomputed dimensions. - Sync — waits for
fastfetch, clears the screen, dumps the output. - Terminal detection — checks
$KITTY_WINDOW_ID,$TERM,$TERM_PROGRAMand pickskittyorsixelprotocol. Defaults tokitty(GPU accelerated). execlptimg — replaces the process itself withtimg(no extra fork, no zombie process). Animated GIF with--loops 0. Pressqto quit and free resources.
fetchlains.c — source
fetchlains.sh — original zsh script (reference)
gif-index — GIF index with precomputed dimensions → copy to ~/.gif-index
margin.txt — fastfetch logo → copy to ~/margin.txt
fastfetch timg gcc# 1. Place the index
mkdir ~/Descargas && cp -r ~/fetchlains/gifs ~/Descargas/
# 2. Place the index
cp gif-index ~/.gif-index
# 3. Place the logo
cp margin.txt ~/margin.txt
# 4. Compile
gcc -O2 -march=native -flto -pipe -s -o fetchlains fetchlains.c
# 5. Install
sudo mv fetchlains /usr/local/bin/fetchlainsFormat: name.gif:width:height. One GIF per line, no spaces.
lain-gift.gif:36:36
lain8.gif:33:33
lain9.gif:37:37
lain1.gif:35:35
lain10.gif:35:35
lain2.gif:35:35
lain4.gif:35:35
lain5.gif:35:35
GIFs live in ~/Descargas/gifs/. To add a new one just append a line to the index — no recompilation needed.
In hyprland.conf:
bind = $mainMod, H, exec, footclient fetchlainsfetchlains.sh |
fetchlains (C) |
|
|---|---|---|
| Startup overhead | ~15ms (zsh) | ~1ms |
| fastfetch + GIF selection | Sequential | Parallel |
| Launching timg | fork + exec | execlp (replaces the process) |
| GIF dimensions | case at runtime |
Read from index |
| Terminal protocol | sixel hardcoded |
Auto-detected (kitty/sixel) |
| Quit | Ctrl+C | q |

