Myfetch
- 6 Devlogs
- 20 Total hours
A fetching program built from scratch in C
A fetching program built from scratch in C
Reads /proc/uptime and parses it. Because the output is in second it gets parsed to seconds
Uses iffaddrs and looks in the linked list of the function for the first non loopback ip address (IPv4)
I usesd getenv(“SHELL”) to get the path of the shell, which i afterwards parsed using strrchr to find the exact name of the shell.
Added a license (MIT and a notice to Fastfetch as some ASCII’s are from the Fastfetch repo), added a README and a workflow.yml (for automated builds).
Sadly the last devlog isn’t that long (maybe thats a good thing tho idk).
The fetching program now reads your main locale from /etc/locale.conf (the LANG= locale) and prints it out.
I added asciis for Ubuntu, Gentoo and a special ascii for distros that currently arent supported. I drew the Ubuntu ascii myself and got the tux and gentoo logo from the fastfetch repo.
There were a few logic errors that resulted from mainly typos/unaware coding. As an example i used strlength as an index for a buffer instead of the designated buffer index variable which resulted in unexpected behavior.
Previously the loop didnt erase during iterations which COULD cause issues in the future. Because of that i added a clear call to the top of the loop. Because of that an issue appeared with cpu fetch (the output was flickering). The fix was to reset the fd during every iteration of the major loop in the function.
The program now displays your current disk usage and your max disk space. This is done by using the sys/statvfs library and getting f_blocks (total size of your drive in blocks) and f_bfree (free space in blocks) and formatting it into GiB.
At the top the program now displays the current user and the hostname of your device. The hostname is read from /etc/hostname and the username accessed by using the pwd library and setting a variable to your pwuid in which your username is stored.
This now displays your current linux kernel version which is read from /proc/version and then parsed and output as most of the rest of the infos of the program
Previously the program spat out somewhat false/misleading stats (partially because of me naming the stats a bit inaccurately). This was as said partially because of me naming it a bit inaccurately but more importantly because the logic was a bit weird. The code of the part responsible for meminfo was different to the concept of the rest of the code and was way harder to read (for me at least) and because of that i made the code conform to the design trend of the other files and now meminfo works great
I still need to get better asciis that have some kind of similar size (the nixos logo is way smaller than the rest, check out the other pictures for reference) and i also need more asciis in general. Overall i think im pretty close to shipping actually
The program now detects what distro your using right now and gives the name and the current version back (/etc/os-releases , PRETTY_NAME). The implementation is similar to the CPU fetch but some of the parsing had to be changed
In addition to the name and the version of your distro the program also displays a ASCII picture of the distro. Currently Debian, Arch and NixOS are supported but i plan to add more. Issue currently is finding appropriate ASCII’s, if you know websites/apps to find ASCII’s of distros please write a comment because the ASCII’s are hard to find
The bug described in the last log was mainly caused by the function that is responsible to create the array of the dynamic value (ae your CPU name), was called on every iteration of the loop. The fix was to move that function(s) to the conditional at the end of every line.
I am currently working on displaying the CPU info but the display is faulty and i havent found the issue yet, but i felt posting a log after 6 hours was necessary. The parsing of /proc/cpuinfo has turned out to be way harder than /proc/meminfo yet its (almost) working.
I made the values refresh after 2 seconds to get an accurate read of the current usage. This is done by looping the meminfo function and most importantly regenerating it by using lseek to reset the index which regenerates the file.
I dont know why but fastfetch is pretty slow on my pc and i dont like htop/btop so my idea (currently) is to build a mix of a fetching program and a task manager like htop/btop
Currently the program displays state of memory/swap even though the dynamic ram stats are a little off right now which i will fix in the next devlogs. Currently the ram info is read from /proc/meminfo using unformatted read/write functions for speed/efficiency