Skip to content

A lightweight macOS utility that automatically monitors directories and deletes .DS_Store files in real-time using the FSEvents API.

License

Notifications You must be signed in to change notification settings

algodesigner/dsmon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dsmon

A macOS utility that automatically monitors and removes .DS_Store files.

Overview

dsmon is a program that monitors directories for .DS_Store file creation and automatically deletes them. This README provides instructions on how to run dsmon from the command line and how to use the dsmon-service.sh script to install and uninstall dsmon as a macOS launchd service.

Running from Command Line

Building

Compile the dsmon binary using the provided Makefile:

make

Usage

Run the dsmon binary with one or more directories to monitor:

./dsmon /path/to/directory1 /path/to/directory2

This will monitor the specified directories for .DS_Store file creation and delete them automatically.

Using dsmon-service.sh Script

The dsmon-service.sh script allows you to install or uninstall dsmon as a macOS launchd service.

Installing the Service

Run the install command with the path to the dsmon binary and the directories to monitor:

./dsmon-service.sh install /path/to/dsmon /path/to/directory1 /path/to/directory2

The script will:

  • Copy the dsmon binary to /usr/local/bin
  • Create a launchd plist file at com.algodesigner.dsmon.plist
  • Load the service using launchctl

Once installed, the service will automatically start and monitor the specified directories.

Enabling Full Disk Access for dsmon

To ensure the dsmon service works properly, you may need to grant it Full Disk Access. This is required because the service monitors and deletes .DS_Store files, which may exist in protected directories.

Steps to Enable Full Disk Access

  1. Open System SettingsPrivacy & SecurityFull Disk Access.
  2. Click the + button to add a new application or binary.
  3. When the file picker opens, press Command + Shift + G to open the "Go to Folder" prompt.
  4. Type or paste the following path: usr/local/bin/dsmon
  5. Press Return.
  6. Select your dsmon binary and click Open.

Once added, the dsmon binary will have the necessary permissions to monitor and delete .DS_Store files in all directories, including protected ones.


Notes

  • You may need to restart the dsmon service after enabling Full Disk Access for the changes to take effect.
  • If you encounter issues with the service not working in certain directories, double-check that Full Disk Access is enabled for the dsmon binary.

Uninstalling the Service

Run the uninstall command:

./dsmon-service.sh uninstall

The script will:

  • Unload the launchd service
  • Remove the plist file from LaunchDaemons
  • Remove the dsmon binary from bin

Monitoring the Service

Check Service Status

  1. Using launchctl:
launchctl list | grep dsmon

If the service is running, you will see its details, including its PID.

  1. Using ps:
ps aux | grep dsmon

This will show all processes related to dsmon.

Viewing Logs

The service logs its output to:

  • dsmon.log - Standard output
  • dsmon_error.log - Error logs

To view the logs:

tail -f dsmon.log

To view error logs:

tail -f dsmon_error.log

Detailed Service Information

Use launchctl to print detailed information about the service:

launchctl print system/com.algodesigner.dsmon

Notes

  • Ensure you have the necessary permissions to run the script and access the directories to monitor
  • The dsmon-service.sh script requires sudo privileges to install or uninstall the service
  • The service will automatically restart on system reboot if installed

Troubleshooting

If you encounter issues:

  1. Check the error logs:
tail -f dsmon_error.log
  1. Verify the following:

    • The directories specified during installation exist and are accessible
    • The dsmon binary is correctly compiled and functional
    • You have the necessary permissions to access the monitored directories
  2. Common issues:

    • Permission denied errors: Ensure you have sudo privileges
    • Service not starting: Check the error logs for specific issues
    • Directories not being monitored: Verify the paths are correct and accessible

License

This project is licensed under the 3-Clause BSD License. See the LICENSE file for details.

Contributing

Feel free to submit issues and pull requests.

About

A lightweight macOS utility that automatically monitors directories and deletes .DS_Store files in real-time using the FSEvents API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published