stardance has been extended another month! the new deadline is october 31 :)

You are browsing as a guest. Sign up (or log in) to start making projects!

Myfetch

  • 6 Devlogs
  • 20 Total hours

A fetching program built from scratch in C

Ship #1 Pending review

A fetching program displaying live information written in C!

What is in it?

A live system-info fetch tool, written in C

What am I proud of?

I’m mostly proud of the general parsing framework I’ve built. I built a parsing framework that reads input line by line (buffer block by buffer block) and extracts information from each line. Even though there is no singular parse() function almost every function that utilizes the parsing framework is very similar (even though slight modifications had to be done because almost no two files are structured the same way)

How is it built?

It’s built in C using ncurses, split across 12 source files, each handling one general task. There is a pre-compiled build that was built with GitHub workflows. The binary can be directly downloaded from the repo’s release page and can be used on (most) glibc-based Linux distros (build is compiled for Ubuntu and ncurses has to be installed on your system).

What I learned

I think the thing I learned the most is how to properly parse files and how to extract information from them. I have never done anything like that before (it’s my second real project ever) and it was really interesting to learn. I also learned how to handle with virtual files from the /proc/ directory (e.g. /proc/cpuinfo, /proc/meminfo etc.) which was rather hard because they don’t exist on your drive.

Known limitations / plans for the future

The project should only work on glibc Linux distros (as mentioned). There are no known bugs currently and according to Valgrind the program is memory-safe. Bugs can still occur and not every system (e.g. dual-socket systems) will work correctly. The project should still work on most systems it’s tested on

Closing word

This project was a lot of fun and genuinely interesting for me. It was the first practical step toward the kind of work I want to do with coding. It was really interesting to see parts of my OS I hadn’t touched before, and it was a great learning experience.

  • 6 devlogs
  • 20h
Try project → See source code →
Open comments for this post

2h 11m 59s logged

LOG 6: LAST LOG BEFORE SHIP, LAST LOG FOR STARDANCE SADLY. UPTIME, IP AND SHELL FETCH

FEATURES

UPTIME FETCH

Reads /proc/uptime and parses it. Because the output is in second it gets parsed to seconds

IP FETCH

Uses iffaddrs and looks in the linked list of the function for the first non loopback ip address (IPv4)

SHELL FETCH

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.

MISC

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).

NOTE

Sadly the last devlog isn’t that long (maybe thats a good thing tho idk).

0
0
13
Open comments for this post

2h 34m 26s logged

LOG 5: LOCALE FETCH, NEW ASCISS, BUG FIXES

FEATURES

LOCALE FETCH

The fetching program now reads your main locale from /etc/locale.conf (the LANG= locale) and prints it out.

NEW ASCIIS

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.

BUG FIXES

LOGIC ERRORS/TYPOS

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.

MISC CHANGES

CLEAR CALL IN MAIN LOOP

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.

0
0
23
Open comments for this post

3h 9m 22s logged

LOG 4: DISK FETCH, HOST/USERNAME FETCH, KERNEL FETCH, MEMINFO REWORK

FEATURES

DISK FETCH

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.

HOST/USERNAME FETCH

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.

KERNEL FETCH

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

FIXES/REWORKS

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

THINGS THAT NEED TO BE DONE

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

0
0
23
Open comments for this post

3h 14m 57s logged

LOG 3: DISTRO FETCH, ASCII LOGOS, CPU FETCH FIX

FEATURES

DISTRO FETCH

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

ASCII LOGOS

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

BUG FIXES

CPU FETCH BUGFIX

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.

0
0
39
Open comments for this post

6h 8m 5s logged

LOG 2: CPUINFO (unfinished), LIVE VALUES

CPUINFO

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.

LIVE VALUES

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.

0
0
40
Open comments for this post

2h 12m 1s logged

LOG 1: MYFETCH, MY OWN CUSTOM FETCHING PROGRAM

IDEA

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

CURRENT FEATURES

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

0
0
22

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…