Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omarazizi/file-specter
A linux daemon that monitors you files
https://github.com/omarazizi/file-specter
c-programming c-programming-language inotify libnotify linux linux-daemon low-level-programming pthreads
Last synced: about 1 month ago
JSON representation
A linux daemon that monitors you files
- Host: GitHub
- URL: https://github.com/omarazizi/file-specter
- Owner: OmarAzizi
- License: mit
- Created: 2024-02-03T16:27:03.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-15T02:15:40.000Z (9 months ago)
- Last Synced: 2024-10-12T17:03:55.178Z (about 1 month ago)
- Topics: c-programming, c-programming-language, inotify, libnotify, linux, linux-daemon, low-level-programming, pthreads
- Language: C
- Homepage:
- Size: 45.9 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flie Specter ⛓️
![C Icon](https://img.shields.io/badge/language-C-blue?style=for-the-badge&logo=c)1. [About File Specter](#about-file-specter)
2. [Demo](#demo)
3. [The Reason Behind This](#the-reason-behind-It)
4. [Installation & Usage](#installation--usage)
5. [Daemon Implementation](#daemon-implementation)
- [Monitoring The Files](#monitoring-the-files)
- [Multithreading](#multithreading)
- [Desktop Notifications](#desktop-notifications)## About File Specter
The file inspector or as I like to call it **File Specter** is a multithreaded Linux [Daemon](https://en.wikipedia.org/wiki/Daemon_(computing)) that monitors your files and notifies you via desktop notifications if they have been accessed.## Demo
https://github.com/OmarAzizi/File-Specter/assets/110500643/bcc2db88-33ef-4cef-9f4d-6d0c0634ef88
## The Reason Behind It
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.## Installation & Usage
In order to install open the terminal and write:
```bash
git clone https://github.com/OmarAzizi/File-Specter.git
```
Then change your directory and build the project:
```bash
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:
```bash
./filespecterd
```## Daemon Implementation
### Monitoring The Files
To monitor the files I used the [inotify API](https://man7.org/linux/man-pages/man7/inotify.7.html), which provides a mechanism for monitoring filesystem events.### Multithreading
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)](https://man7.org/linux/man-pages/man7/pthreads.7.html).### Desktop Notifications
To show the user that his file has been accessed, instead of printing it to the **syslog**, I used the [libnotify](https://developer-old.gnome.org/libnotify/unstable/ch01.html) notification API to do that in real-time.