The file inspector or as I like to call it File Specter is a multithreaded Linux Daemon that monitors your files and notifies you via desktop notifications if they have been accessed.
Screencast.from.2024-02-04.21-43-09.mp4
The main reason I created this daemon is primarily because I'm trying to teach myself systems-level programming in UNIX-based systems and familiarize myself with the available system libraries and their APIs. So this is probably not the best way I could write a daemon as I'm still learning. Therefore, if you have any suggestions for improvement or if you spot any bugs, you can contribute to this repository or reach out to me, so I can learn from it.
In order to install open the terminal and write:
git clone https://github.com/OmarAzizi/File-Specter.git
Then change your directory and build the project:
cd File-Specter
make filespecter
To run it properly you need to give it the path to the file you want to monitor, so you need to run it as follows:
./filespecterd <path>
To monitor the files I used the inotify API, which provides a mechanism for monitoring filesystem events.
I used threads in the daemon so that instead of doing the work sequentially, it can monitor the file and report any changes or access to it on different threads. Therefore, they run in parallel and they wont wait for each other to finish executing inorder to run. To get that done, I used the POSIX threads (Pthreads).
To show the user that his file has been accessed, instead of printing it to the syslog, I used the libnotify notification API to do that in real-time.