An intelligent, offline disk space manager built with OS-level system calls
Features β’ Demo β’ Installation β’ Usage β’ Documentation
SpaceMate is a lightweight, privacy-first disk space management tool that operates at the OS level using system calls. Unlike bloated commercial alternatives, SpaceMate provides intelligent storage analysis, duplicate detection, and safe cleanupβall while running completely offline with zero third-party dependencies.
Modern systems accumulate clutter over time:
- π¦ Duplicate files waste valuable storage
- ποΈ Temporary files pile up unnoticed
- π Users lack visibility into disk usage patterns
β οΈ Manual cleanup is time-consuming and risky
SpaceMate automates intelligent disk management while keeping you in control:
- Real-time monitoring with visual insights
- Smart detection of redundant and unnecessary files
- Safe cleanup with automatic backups
- Zero installation, no login required, completely private
- Real-time Disk Monitoring - Track storage usage across all mounted filesystems
- Directory Tree Visualization - See what's consuming your space at a glance
- Smart File Categorization - Automatically group files by type, size, and age
- Duplicate Detection - Hash-based identification of duplicate files
- Large File Scanner - Quickly locate space hogs
- Interactive Cleanup Mode - Review before you delete
- Dry-Run Simulation - Preview cleanup actions without making changes
- Automatic Backups - All deletions backed up before removal
- Protected Directories - System-critical paths are whitelisted
- Operation Logging - Complete audit trail of all actions
- 100% Offline - No cloud, no tracking, no telemetry
- Local Processing - All analysis happens on your machine
- Open Source - Transparent, auditable code
- No Root Required - Runs with standard user permissions (for user directories)
- Dual Interface - Both CLI and GUI options
- Command-Line Interface - Fast, scriptable, and lightweight
- Graphical Interface - Intuitive Qt5-based GUI with tabs
- Color-Coded Output - Easy-to-read terminal displays and visual storage breakdown
- Progress Indicators - Real-time progress for scanning and operations
- Detailed Reports - Activity logging and monitoring statistics
- Cross-Platform - Works on Linux and WSL2
# Scan your Downloads folder
$ ./spacemate scan ~/Downloads
SpaceMate v1.0 - Smart Disk Manager
====================================
β Scanned 1,847 files in 2.4 seconds
Disk Usage: 39.2 GB / 50.0 GB (78.4%) [βββββββββββββββββββββββββ]
Free Space: 10.8 GB
β οΈ Warning: Disk usage above 75%# Analyze for duplicates and waste
$ ./spacemate analyze ~/Downloads
π Analysis Complete!
ββββββββββββββββββββββββββββββββββββββββββββββ
Found Issues:
π 47 duplicate files β 6.2 GB wasted
ποΈ 23 temporary files β 1.4 GB reclaimable
β° 89 old files (90+ days) β 8.9 GB unused
π‘ Potential Space Savings: 16.5 GB# Preview cleanup (no changes made)
$ ./spacemate clean ~/Downloads --dry-run
Would delete:
β 44 duplicate copies 6.2 GB
β 23 temporary files 1.4 GB
β 15 cache files 892 MB
After cleanup:
Free space: 10.8 GB β 19.3 GB
Usage: 78.4% β 61.4%
# Proceed with actual cleanup
$ ./spacemate clean ~/Downloads
π Creating backup...
β Backup saved to ~/.spacemate_backup/2025-10-03/
ποΈ Cleaning up... [ββββββββββββββββββββ] 100%
β Removed 82 files, freed 8.5 GBπΈ View Interface Screenshots (Click to expand)
ββββββββββββββββββββββββββββββββββββββββββ
β SpaceMate - Smart Disk Manager β
β Team Raptors #057 β
ββββββββββββββββββββββββββββββββββββββββββ
Usage: ./spacemate <command> <path> [options]
Commands:
scan <path> - Scan disk usage and show statistics
analyze <path> - Analyze files (duplicates, temp files, old files)
clean <path> - Clean up unnecessary files
restore - Restore backed up files
help - Show this help message
ββββββββββββββββββββββββββββββββββββββββββ
β DISK USAGE β
β βββββββββββββββββββββββββββββββββββββββββ£
β Total: 256 GB β
β Used: 192 GB (75%) β
β Free: 64 GB β
β β
β [βββββββββββββββββββββββββββ] β
β Documents | Images | Apps | Free β
ββββββββββββββββββββββββββββββββββββββββββ
[Start Monitoring] [Stop Monitoring]
Activity Log:
15:30:45 - Monitoring started for: /home/user/Downloads
15:30:46 - Found 1,234 files, 567 folders
15:30:46 - Documents: 234 files (2.4 GB)
15:30:46 - Images: 456 files (8.9 GB)
Path: /home/user/Downloads [Browse]
[Analyze]
Progress: [ββββββββββββββββββββ] 100%
Status: Analysis complete
Results:
- Total files scanned: 1,234
- Duplicates found: 47 files (6.2 GB)
- Temp files: 23 files (1.4 GB)
- Old files (45+ days): 89 files (8.9 GB)
Duplicate Files:
βββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββ
β File Path β Size β
βββββββββββββββββββββββββββββββββββββββββββΌβββββββββββ€
β /home/user/Downloads/movie_copy.mp4 β 1.4 GB β
β /home/user/Downloads/movie_copy2.mp4 β 1.4 GB β
β /home/user/Downloads/photo_backup.jpg β 5.2 MB β
βββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββ
[Select All Duplicates] [Delete Selected Files]
Space to recover: 2.8 GB
Existing Backups:
βββββββββββββββββββββββββββ¬ββββββββββββββ¬βββββββββββ
β Timestamp β File Path β Size β
βββββββββββββββββββββββββββΌββββββββββββββΌβββββββββββ€
β 2025-11-11 14:30:22 β movie.mp4 β 1.4 GB β
β 2025-11-11 14:30:25 β photo.jpg β 5.2 MB β
βββββββββββββββββββββββββββ΄ββββββββββββββ΄βββββββββββ
[Restore Selected]
- Operating System: Linux (Ubuntu 20.04+, Debian, Fedora, Arch) or WSL2 on Windows
- Compiler: GCC/G++ 9.0 or higher with C++17 support
- Build Tools: CMake 3.10+, make
- GUI Requirements: Qt5 (qt5-default, qt5-qmake, qtbase5-dev)
- Optional: OpenSSL for enhanced hashing
# Clone the repository
git clone https://github.com/itsmnx/Space-Mate.git
cd Space-Mate
# Install dependencies (Ubuntu/Debian)
sudo apt update
sudo apt install build-essential cmake qt5-default qtbase5-dev libqt5widgets5
# For WSL users, install X11 server support
# Download and install VcXsrv: https://sourceforge.net/projects/vcxsrv/
# Create build directory and compile
mkdir -p build
cd build
cmake ..
make -j4
# Verify build
ls -lh spacemate_cli SpacemateGUIAfter successful build, you'll have:
- spacemate_cli (~295 KB) - Command-line executable
- SpacemateGUI (~802 KB) - Graphical user interface executable
# Clean build
cd build
make clean
cmake ..
make -j4
# Build with verbose output
make VERBOSE=1
# Run from build directory
./spacemate_cli help
./SpacemateGUI # (with DISPLAY=:0 in WSL)SpaceMate provides both CLI (Command-Line Interface) and GUI (Graphical User Interface) options.
# Navigate to build directory
cd build
# Display help
./spacemate_cli help
# Scan a directory for disk usage
./spacemate_cli scan <path>
# Analyze files (duplicates, temp files, old files)
./spacemate_cli analyze <path>
# Clean up (with confirmation)
./spacemate_cli clean <path>
# Restore deleted files
./spacemate_cli restore# Verbose output
./spacemate_cli scan /path --verbose
./spacemate_cli analyze /path --verbose
# Dry run (preview only, no changes)
./spacemate_cli clean /path --dry-run
# Force mode (skip confirmations)
./spacemate_cli clean /path --force
# Combine options
./spacemate_cli clean /path --dry-run --verboseFrom WSL (Linux Environment):
cd build
export DISPLAY=:0
./SpacemateGUIFrom Windows PowerShell:
# Using batch file (from project root)
.\spacemate.bat gui
# Or using WSL command directly
wsl -e bash -ic "cd /mnt/c/Users/YOUR_USERNAME/path/to/Spacemate/build && export DISPLAY=:0 && ./SpacemateGUI"Dashboard Tab:
- View real-time disk usage statistics
- Color-coded storage visualization:
- π΅ Blue: Documents (PDF, DOCX, TXT, etc.)
- π’ Green: Images (JPG, PNG, GIF, etc.)
- π£ Purple: Applications & Executables
- π Orange: System Files
- βͺ Gray: Free Space
- Monitor specific folders with file/folder counts
- Start/Stop real-time monitoring
Analyze Tab:
- Browse and select folders to scan
- Real-time progress updates during analysis
- Automatic detection of:
- Duplicate files (MD5 hash-based)
- Temporary files (.tmp, .temp, .log, .cache)
- Old files (45+ days without modification)
Cleanup Tab:
- View detected duplicate files in a table
- Select individual files or use "Select All Duplicates"
- Preview total space savings before deletion
- Safe deletion with automatic backup
- Clear display with file paths and sizes
Backup Tab:
- Browse all backed-up files
- View backup timestamps and file sizes
- Restore individual files with one click
- Automatic backup index management
Activity Log:
- Real-time activity monitoring
- Detailed statistics:
- Total files and folders in monitored location
- File counts by category (Documents, Images, Videos, etc.)
- Total size breakdown
- 24-hour timestamp format
- Auto-scroll to latest entries
For Windows with WSL:
-
Install an X11 server (VcXsrv recommended):
- Download from: https://sourceforge.net/projects/vcxsrv/
- Launch XLaunch
- Choose "Multiple windows"
- Display number: 0
- Enable "Disable access control"
-
Verify X11 server is running:
# In WSL terminal echo $DISPLAY # Should show :0
Create ~/.spacematerc for custom settings:
# SpaceMate Configuration
[general]
backup_dir = ~/.spacemate/backups
log_level = info
[cleanup]
auto_backup = true
confirm_deletions = true
backup_retention_days = 30
[analysis]
duplicate_threshold = 100
old_file_days = 45cd build
# Step 1: See what's taking space
./spacemate_cli scan ~/Downloads
# Step 2: Find problems
./spacemate_cli analyze ~/Downloads
# Step 3: Preview cleanup
./spacemate_cli clean ~/Downloads --dry-run
# Step 4: Clean it up
./spacemate_cli clean ~/Downloads- Launch GUI: Run
.\spacemate.bat guifrom project root - Dashboard: View current disk usage and storage breakdown
- Analyze:
- Switch to Analyze tab
- Click "Browse" to select folder
- Click "Analyze" and wait for scan completion
- Cleanup:
- Switch to Cleanup tab
- Review duplicate files
- Click "Select All Duplicates" or select individual files
- Click "Delete Selected Files"
- Confirm deletion
- Monitor:
- Return to Dashboard
- Click "Start Monitoring" to track folder statistics in real-time
- View updates in Activity Log
- Restore (if needed):
- Go to Backup tab
- Select file to restore
- Click "Restore Selected"
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interface Layer β
β ββββββββββββββββββββ ββββββββββββββββββββ β
β β CLI Interface β β GUI (Qt5) β β
β β (main.cpp) β β (mainwindow) β β
β ββββββββββ¬ββββββββββ ββββββββββ¬ββββββββββ β
ββββββββββββββββββββΌβββββββββββββββββββββββΌβββββββββββββββββββ
β β
βββββββββββ΄ββββββββββββββββββββββββ΄ββββββββββ
β β
ββββββββββΌβββββββββββ βββββββββΌβββββββββ βββββββΌβββββββββββ
β Disk Monitor β β File Analyzer β β Cleanup Managerβ
β - QStorageInfo β β - QDir/QFile β β - Safe delete β
β - statvfs() β β - MD5 hashing β β - File backup β
β - Filesystem β β - Categorize β β - Logging β
β statistics β β - Duplicates β β β
ββββββββββ¬βββββββββββ ββββββββββ¬βββββββββ ββββββββββ¬ββββββββ
β β β
ββββββββββββββββββββββββββΌβββββββββββββββββββββββ
β
ββββββββββΌββββββββββ
β Backup Manager β
β - Create backups β
β - Restore files β
β - Index tracking β
ββββββββββββββββββββ
| Module | Files | Responsibility | Key Technologies |
|---|---|---|---|
| CLI Interface | main.cpp |
Command-line argument parsing | C++ iostream, getopt |
| GUI Interface | gui/mainwindow.cpp, gui/mainwindow.h |
Graphical user interface | Qt5 Widgets, Signals/Slots |
| Disk Monitor | core/disk_monitor.cpp, include/disk_monitor.h |
Track filesystem statistics | QStorageInfo, statvfs() |
| File Analyzer | core/file_analyzer.cpp, include/file_analyzer.h |
Scan, categorize, detect duplicates | QCryptographicHash, std::filesystem |
| Cleanup Manager | core/cleanup_manager.cpp, include/cleanup_manager.h |
Safe file deletion with backups | QFile::remove(), logging |
| Backup Manager | core/backup_manager.cpp, include/backup_manager.h |
Backup & restore operations | QFile::copy(), JSON index |
| Utilities | core/utils.cpp, include/utils.h |
Helper functions | String formatting, file ops |
Algorithm: MD5 Hash-Based Duplicate Detection
Time Complexity: O(n log n)
Space Complexity: O(n)
1. Scan all files in directory (recursive)
2. For each file:
- Compute MD5 hash using QCryptographicHash
- Store in hash map: hash -> list of file paths
3. Identify hash collisions (same hash = duplicates)
4. Group duplicates and report to user
Algorithm: Recursive Filesystem Traversal
Time Complexity: O(n) where n = number of files
Space Complexity: O(d) where d = max directory depth
1. Start from root directory using QDir
2. For each entry:
- If file: collect metadata (size, mtime, path)
- If directory: recurse into subdirectory
3. Categorize files by extension
4. Accumulate sizes and statistics
Algorithm: Two-Phase Cleanup
Phase 1: Backup
- For each file to delete:
* Create backup directory (~/.spacemate/backups/)
* Copy file to backup location
* Record metadata in backup index
* Verify backup success
Phase 2: Delete
- Verify all backups successful
- Delete original files using QFile::remove()
- Log all operations with timestamp
- Update activity log
- On failure: halt and report error
# Navigate to tests directory
cd tests
# Run test script
./run_tests.sh
# Manual testing of CLI
cd ../build
./spacemate_cli help
./spacemate_cli scan /tmp
./spacemate_cli analyze /tmp
# Manual testing of GUI
export DISPLAY=:0
./SpacemateGUICLI Testing:
# Test 1: Basic help
./spacemate_cli help
# Test 2: Scan directory
./spacemate_cli scan ~/Downloads
# Test 3: Analyze for duplicates
./spacemate_cli analyze ~/Documents --verbose
# Test 4: Dry-run cleanup
./spacemate_cli clean ~/temp --dry-run
# Test 5: Actual cleanup
./spacemate_cli clean ~/temp
# Test 6: Restore backup
./spacemate_cli restoreGUI Testing:
- Launch GUI successfully
- Navigate all tabs (Dashboard, Analyze, Cleanup, Backup)
- Scan a folder with "Analyze"
- View duplicates in Cleanup tab
- Select and delete files
- Verify backup in Backup tab
- Restore a file
- Start/stop monitoring
- Check activity log updates
We welcome contributions from the community! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
# Clone your fork
git clone https://github.com/your-username/spacemate.git
cd spacemate
# Create development branch
git checkout -b dev
# Make changes and test
make clean && make debug
make test
# Commit with meaningful messages
git commit -m "feat: add new duplicate detection algorithm"- Follow K&R C style guidelines
- Add comments for complex logic
- Write unit tests for new features
- Update documentation
- Keep functions under 50 lines when possible
- π Bug fixes and issue resolution
- β¨ New features (see Issues)
- π Documentation improvements
- π§ͺ Additional test coverage
- π Localization and i18n
- π¨ GUI development (Qt/GTK)
- CLI Executable: ~295 KB
- GUI Executable: ~802 KB
- Build Time: ~15-20 seconds (with make -j4)
- Qt Version: Qt 5.x
- C++ Standard: C++17
| Operation | Scale | Expected Performance |
|---|---|---|
| Scan Directory | 1,000 files | < 2 seconds |
| Scan Directory | 10,000 files | < 10 seconds |
| Duplicate Detection | 1,000 files | < 5 seconds |
| MD5 Hash Calculation | Per file | ~1-2 MB/ms |
| File Cleanup | 100 files | < 1 second |
| GUI Launch | - | < 2 seconds |
- Multi-threaded scanning for large directories
- Efficient MD5 hashing with QCryptographicHash
- Lazy loading for GUI tables
- Real-time progress updates during operations
- Minimal memory footprint (~50-100 MB typical usage)
Issue: Permission denied errors
# Solution: Run with appropriate permissions
./spacemate_cli scan /home/user # Works
./spacemate_cli scan /root # Needs sudoIssue: GUI doesn't launch in WSL
# Solution 1: Check X11 server is running
# - Launch VcXsrv on Windows
# - Verify display: echo $DISPLAY (should show :0)
# Solution 2: Set DISPLAY environment variable
export DISPLAY=:0
./SpacemateGUI
# Solution 3: Use batch file from project root
# (In Windows PowerShell)
.\spacemate.bat guiIssue: Qt permission warning in WSL
QStandardPaths: wrong permissions on runtime directory /run/user/1000/
# Solution: This is harmless and can be ignored
# It does not affect functionality
# Or fix permissions:
chmod 0700 /run/user/1000/Issue: Build errors with Qt
# Solution: Install Qt5 development packages
sudo apt install qt5-default qtbase5-dev libqt5widgets5
# Rebuild
cd build
cmake ..
make clean && make -j4Issue: "spacemate_cli: command not found"
# Solution: Make sure you're in the build directory
cd /path/to/Spacemate/build
./spacemate_cli help # Note the ./# Check build output
cd build
ls -lh spacemate_cli SpacemateGUI
# Test CLI
./spacemate_cli help
# Test GUI (with verbose X11 output)
export DISPLAY=:0
./SpacemateGUI --verbose
# Check activity logs in GUI
# Navigate to Dashboard > Activity Log tab- π§ Email: jmanas275@gmail.com
- π Issues: GitHub Issues
- οΏ½ Repository: GitHub
- οΏ½ Documentation: See run.md for detailed running instructions
- Running Instructions - Detailed CLI and GUI commands
- Setup Guide - Automated setup script for dependencies
- CMake Configuration - Build system configuration
- Project Structure:
build/- Compiled executables (spacemate_cli, SpacemateGUI)core/- Core implementation files (.cpp)gui/- GUI implementation (Qt5)include/- Header files (.h)logs/- Application logstests/- Test scripts
- CLI disk usage monitoring
- Directory scanning and analysis
- MD5-based duplicate detection
- Safe cleanup with backup
- Backup and restore system
- Qt5 GUI interface
- Real-time monitoring
- Activity logging
- Color-coded storage visualization
- Segmented storage breakdown by file type
- Auto-delete files older than 45 days
- Folder-specific monitoring
- Scheduled cleanup tasks
- Advanced filtering options
- Configuration profiles
- Export reports to CSV/JSON
- Real filesystem scanning for accurate categorization
- Machine learning for smart recommendations
- Network drive support
- Multi-user support
- Plugin system
- Windows native GUI (non-WSL)
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 Team Raptors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
- Course: Operating Systems (OS-T057)
- Institution: BTech Computer Science & Engineering
- Inspired by: Unix utilities (du, df, fsck)
- References:
- A. S. Tanenbaum - Modern Operating Systems
- W. Stallings - Operating Systems: Internals and Design Principles
- Linux Kernel Documentation
- Our course instructors for guidance
- The open-source community for inspiration
- Linux kernel developers for excellent documentation
- Email: jmanas275@gmail.com
- β Star this repo to show support
- π Watch for updates and releases
- π΄ Fork to contribute
Made with β€οΈ by Team Raptors
If you found SpaceMate helpful, please consider giving it a β!