Skip to content

Devel info

Federico edited this page Nov 16, 2016 · 11 revisions

Why ncursesFM?

I always wanted to get into system level programming, and this was absolutely one of the best way i could achieve that.
Moreover, i felt like a really user-friendly, easy to use CLI FM was missing (i mean, something that is as easy as a graphical FM). But this is just my own opinion.
And i wanted to build a fast and lightweight FM, using latest APIs. You can see that ncursesFM uses sd-bus api, that has been made public on 19 Jun 2015. Moreover, it already uses copy_file_range syscall (https://lwn.net/Articles/659523/), added in linux 4.5, if a recent enough kernel version is found.

Why ncurses? Why not fully graphical?

First of all, i already used ncurses so i felt pretty comfortable using it.
Using ncurses allowed me to build a very lightweight and simple project, with very few deps.
Finally, this way ncursesFM can be used through remote (eg ssh).

Technical details

I wanted to use as few fork calls as possible. You only see 2 of them, i did everything else in code.
I use vfork only to call xdg-open and $EDITOR to open files.

Moreover, i wanted my FM to gracefully manage external signals (SIGINT/SIGTERM), so i used a poll (http://linux.die.net/man/2/poll) together with a signalfd (http://man7.org/linux/man-pages/man2/signalfd.2.html).
Using poll allowed me to only run one thread. This leaded to a cleaner and simple code, with no locking/sync issues, no mutexes, fewer resource usage.
Obviously i use some worker threads to avoid locking UI, but that is started only when a long job (pasting a file, installing a package) is requested; normally only one thread will be running (ie, the main thread).

Finally, i tried to follow standards. I therefore made use of libudev, libsystemd, libarchive, libmagic (all widely used libraries), i added inotify and xdg user dirs support (for bookmarks), i used nftw functions, GNU getopt, etc etc.

I'd like to add more comments/doc to the code, as i really struggled finding proper code examples and doc for some libraries. So i hope ncursesFM code can help other devs to understand how these libraries work, with proper examples and explanations.
This is, and will be, one of the main aim of this project.

Clone this wiki locally