A macOS utility that automatically monitors and removes .DS_Store files.
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.
Compile the dsmon binary using the provided Makefile:
makeRun the dsmon binary with one or more directories to monitor:
./dsmon /path/to/directory1 /path/to/directory2This will monitor the specified directories for .DS_Store file creation and delete them automatically.
The dsmon-service.sh script allows you to install or uninstall dsmon as a macOS launchd 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/directory2The 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.
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.
- Open System Settings → Privacy & Security → Full Disk Access.
- Click the + button to add a new application or binary.
- When the file picker opens, press Command + Shift + G to open the "Go to Folder" prompt.
- Type or paste the following path:
usr/local/bin/dsmon - Press Return.
- Select your
dsmonbinary 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.
- You may need to restart the
dsmonservice 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
dsmonbinary.
Run the uninstall command:
./dsmon-service.sh uninstallThe script will:
- Unload the launchd service
- Remove the plist file from LaunchDaemons
- Remove the dsmon binary from bin
- Using launchctl:
launchctl list | grep dsmonIf the service is running, you will see its details, including its PID.
- Using ps:
ps aux | grep dsmonThis will show all processes related to dsmon.
The service logs its output to:
dsmon.log- Standard outputdsmon_error.log- Error logs
To view the logs:
tail -f dsmon.logTo view error logs:
tail -f dsmon_error.logUse launchctl to print detailed information about the service:
launchctl print system/com.algodesigner.dsmon- Ensure you have the necessary permissions to run the script and access the directories to monitor
- The
dsmon-service.shscript requires sudo privileges to install or uninstall the service - The service will automatically restart on system reboot if installed
If you encounter issues:
- Check the error logs:
tail -f dsmon_error.log-
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
-
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
This project is licensed under the 3-Clause BSD License. See the LICENSE file for details.
Feel free to submit issues and pull requests.