|:.:.:.:.:.:.:.:.:/.:.:.:.:.:./.:.:.:.:.:.:.:.:.:.:.:.:.:./|   '. :.:.:.:.:.:.:.:.:.:.l.ヽ:.:.:.:.l:.:.:.:.:.:.:.:.:.:∧\:.:.:.',
          |:.:.:.:.:.:.:./.:.:.:.:.:./.:.:.:.:.:.:.:.:.:.:.:.: , ′   l :.:.:.:.:.:.:.:.:.:| ∨.:.:.l:.:.:.:.:.:.:.:.:.:.∧ \:.'.
          |:.:.:.:.:.:/.:.:.:.:.: /.:.:.:.:.:.:.:.:. ヽ/ /    |:.:.:.:.:.:.:./:.:.|   y'.:.:|:.:.:.:.|:.:.:.:.:.:.∧   ヘ.
          |:.:.:.:./.:.:.:.//.:.:.:.:.:.:.:.:.:.:/ \,′   !:.:.:.:.:.:/|:.:./,/ '.:.:| :.:.:.|:.:.:.:.:.:.:.:.|
          |:.:.:/.:.:./.:./.:.:.:.:.:.:.:.:./   /` ‐-‐'|:.:.:./ |ァ'´    |:.:| :.:.:.|:.:.:.:.:.:.:.:.|
          |:.:.i.:.:./.:.:.: '.:.:.:.:.:.:.:/   ,/       |:.:.:/   ′    }.:.| :.:.:.|:.:.:.| :.:.:.:|
          |:.:.|:./.: rヘ|:.:.:.:.:.:/:.| 三三三三三  |:./   三三三 ハ|:.:.:.:.|:.:.:.| :.:.:.:|
          |:.:.l〃.:{  |:.:.:.:./.:.:.|             l.'         .i.:.:.i.:.:.:∧ :.:|ヽ :.:|
          |:.:./.:.:.:.\|:.:.:/.:.:.:.:|                '       |:.:.||:.:/  :.:.| '.:.:l
          |:./.:.:.:.:.:.:. !:./.:.:.:.:.:.'、            ,.ー--、    }.:.:|レ′ ∨  V
          |/.:.:.:.:.:.:.:.:V '´  ̄`ヽ.、            ´`¨¨{. |_.  '.:.:.:.|
         /.:.:.:.:.:.:.:./         ヘ `    . __. -r1 |:.:.:.:.:.:.:.:.|
         :.:.:.:.:.:.:, '         '. \    | _.   -┴ー──┴┐
         :.:.:.:.:./           |  \  r' |   -──────i'
    

< KONAKONA.MOE >

How to Dump Neofetch Output into an Image

Last Mod.: 2024-06-02 | Created On: 2024-03-09


I thought it was a cool idea to have a cronjob on the server hosting my website “dump” the neofetch system status output into an image that I could use on my site, flexing that uptime and to have some more dynamic things on my static website.

I found that the simplest solution was to do this with a package called ansilove. Here is the result:

Fetch

You can also see this on the About section of my site.

And this is the very small script that I made to set as my cronjob. Source

 1#!/bin/sh
 2
 3temp=$(mktemp)
 4header="Generated on $(date +"%Y-%m-%d %H:%M %Z")"
 5location="/var/www/konakona/fetch.png"
 6
 7printf "%s\n" "$header" >> "$temp"
 8neofetch >> "$temp"
 9
10rm "$location"
11ansilove -o "$location" "$temp"
12rm $temp

After copying or downloading it, edit the script changing the location of where you want to save the image, and the header text if you want. Then set it as executable with chmod +x fetchpng and copy it to your $PATH, for example to /usr/local/bin/.

Now of course make sure to download ansilove and neofetch, which are both on the Debian 12 repository.

Now we need to add the cronjob, I like using the root user here so I’m 100% certain that the image will be generated into that directory.

sudo crontab -eu root

1*/10 * * * * /usr/local/bin/fetchpng # 10 minute example

Now save it and you will have an usable image being generated each 10 minutes in the root of your website.

Note: I like uploading my site with rsync, so I have to add some exclusions so that it doesn’t exclude this image when I’m uploading my site

This can be done with the --exclude='fetch.png' flag.


Prev:
How to install Zipline (ShareX/File Upload Server)
Next:
LTT's Opinion on Ad Blockers Nonsense