Skip to content

ArtNazarov/DesktopFileCleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Desktop File Cleaner

A Qt GUI application for Linux that scans for and removes broken desktop application entries (.desktop files) whose executables no longer exist.

Screenshot

screenshot of DesktopFileCleaner

Features

  • 🔍 Scan for broken desktop files: Automatically searches standard desktop file locations
  • 🔐 Superuser support: Uses sudo credentials to read and delete system-owned files
  • 🗑️ Batch deletion: Select multiple broken files and delete them all at once
  • 🎨 Visual indicators: Root-owned files are highlighted in red
  • Select/deselect all: Easily manage multiple files with a single click
  • 📋 Detailed information: Shows application names and file paths with tooltips

Supported Desktop File Locations

  • ~/.local/share/applications/
  • /usr/share/applications/
  • /usr/local/share/applications/
  • /var/lib/flatpak/exports/share/applications/
  • ~/.local/share/flatpak/exports/share/applications/

Requirements

Build Dependencies

  • Qt 5 or Qt 6 with development packages
  • C++ compiler with C++11 support
  • Make or Ninja build system
  • qmake (usually included with Qt)

Ubuntu/Debian

sudo apt install qtbase5-dev qt5-qmake g++ make

Fedora/RHEL

sudo dnf install qt5-qtbase-devel gcc-c++ make

Arch Linux

sudo pacman -S qt5-base

Runtime Dependencies

  • sudo for managing root-owned files
  • Standard Linux desktop environment

Building from Source

Clone the Repository

git clone https://github.com/ArtNazarov/DesktopFileCleaner.git
cd DesktopFileCleaner

Build the Application

Using qmake (recommended)

# Clean previous builds (if any)
make clean 2>/dev/null || true
rm -f DesktopFileCleaner moc_* 2>/dev/null || true

# Generate Makefile and build
qmake DesktopFileCleaner.pro
make

Using CMake (alternative)

mkdir build
cd build
cmake ..
make

Install (Optional)

# Copy executable to /usr/local/bin
sudo cp DesktopFileCleaner /usr/local/bin/

# Or run directly from build directory
./DesktopFileCleaner

Usage

  1. Launch the application

    ./DesktopFileCleaner
  2. Enter credentials (if checking system files)

    • Username: Your sudo username (defaults to current user)
    • Password: Your sudo password
  3. Scan for broken files

    • Click "Find Broken Desktop Files" button
    • The application will scan all desktop file locations
    • Broken files will appear in the list with checkboxes
  4. Review and select files

    • Files requiring sudo permissions are shown in red
    • Hover over files to see full paths
    • Use "Select/Deselect All" checkbox to manage multiple files
  5. Delete selected files

    • Select the files you want to remove
    • Click "Delete Selected Files" button
    • Confirm the deletion when prompted

How It Works

  1. File Discovery: The app scans standard desktop file directories
  2. Permission Handling:
    • User-owned files are read directly
    • Root-owned files are read using sudo credentials
  3. Broken File Detection:
    • Extracts the Exec= line from each .desktop file
    • Checks if the executable exists and is executable
    • Accounts for both absolute paths and PATH-resolved executables
  4. File Deletion:
    • User-owned files are deleted directly
    • Root-owned files are deleted using sudo

Security Notes

⚠️ Important Security Information

  • Password handling: The application temporarily stores your sudo password in memory while scanning and deleting files
  • File operations: The app only modifies .desktop files, not executables
  • Superuser access: Requires sudo privileges to manage system-wide desktop files
  • Recommendation: Review the source code before entering sensitive credentials

For enhanced security, consider:

  • Running the application in a sandboxed environment
  • Using a dedicated sudo configuration with limited permissions
  • Reviewing which files will be deleted before confirming

Troubleshooting

Common Issues

  1. "No desktop files found"

    • Ensure you have read permissions for desktop directories
    • Enter sudo credentials if checking system files
  2. "Permission denied" when deleting

    • Make sure sudo credentials are correct
    • Check if the file still exists
    • Verify you have appropriate permissions
  3. Build errors

    • Ensure all Qt development packages are installed
    • Check Qt version compatibility
    • Clean build directory and rebuild
  4. Missing system desktop files

    • The app shows system files only when sudo credentials are provided
    • Enter your sudo password to see all files

Debug Mode

Enable debug output by rebuilding with:

qmake "CONFIG+=debug" DesktopFileCleaner.pro
make clean
make

Author

Nazarov A.A., Orenburg, Russia, 2025

License

This project is licensed under the MIT License

Note: Always back up important files before using cleanup utilities. Use this tool at your own risk.

About

A Qt GUI application for Linux that scans for and removes broken desktop application entries (.desktop files) whose executables no longer exist.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors