A macOS utility that watches folders for new image and PDF files and automatically opens them in Preview.
- Learning project: Built to understand file system monitoring and macOS automation
- Practical utility: Automatically opens new images and PDFs in Preview
- Smart design: Prevents duplicate openings with intelligent throttling
- Well-documented: Comprehensive testing, documentation, and development tools
- Real-time monitoring: Watches specified directories for new files
- Smart throttling: Prevents duplicate file openings with configurable cache TTL
- Audio feedback: Plays a system sound when files are opened
- Comprehensive logging: All events are logged for debugging
- Multiple file types: Supports images (JPG, PNG, WebP, GIF, HEIC) and PDFs
- macOS (uses
fswatchandafplay) fswatchcommand-line tool
First, install the required fswatch tool:
# Using Homebrew (recommended)
brew install fswatch
# Or using MacPorts
sudo port install fswatch- Clone this repository:
git clone https://github.com/funkatron/speedy-delivery.git
cd speedy-delivery- Install using the Makefile (recommended):
make installOr install manually:
# Make the script executable
chmod +x speedy-delivery
# Add to your PATH
sudo ln -s "$(pwd)/speedy-delivery" /usr/local/bin/speedy-deliveryOr use the installation script:
./install.sh-
Install dependencies:
brew install fswatch
-
Clone and install:
git clone https://github.com/funkatron/speedy-delivery.git cd speedy-delivery make install -
Start watching:
speedy-delivery ~/Downloads -
Test it: Drop an image or PDF into
~/Downloadsand watch it open automatically!
The project includes a comprehensive Makefile for common tasks:
make help # Show all available commands
make test-clean # Run comprehensive tests
make smoke-test # Demonstrate functionality
make lint # Check script syntax
make install # Install to system
make uninstall # Remove from systemWatch the default directory (~/Desktop/watch_images):
./speedy-deliveryWatch one or more directories:
./speedy-delivery ~/Downloads ~/Desktop/screenshotsShow usage information:
./speedy-delivery --help# Start watching your Downloads folder
speedy-delivery ~/Downloads
# Now when you download images or PDFs, they'll open automatically!
# Try downloading a screenshot or PDF to see it in action# Watch both Downloads and a screenshots folder
speedy-delivery ~/Downloads ~/Desktop/screenshots
# Files in either folder will be opened automatically# Watch a project's assets folder
speedy-delivery ~/my-project/assets
# When you save images from your design tools, they open instantly
# Great for reviewing design assets as you work# Run the smoke test to see it work
make smoke-test
# Or test in isolation
./test/clean-test.sh# Start the tool and watch logs in real-time
speedy-delivery ~/Downloads &
tail -f ~/Library/Logs/speedy-delivery.log
# Now drop files and watch the logs show what's happeningThe script ignores files that were opened within the last 10 seconds to prevent duplicate launches. You can modify this by changing the CACHE_TTL variable in the script.
All events are logged to ~/Library/Logs/speedy-delivery.log. Check this file for debugging information.
File timestamps are cached in ~/.cache/speedy-delivery/ to implement the throttling mechanism.
# Good: Watch specific folders
speedy-delivery ~/Downloads ~/Desktop/screenshots
# Avoid: Watching entire home directory
speedy-delivery ~# Start in background
speedy-delivery ~/Downloads &
SPEEDY_PID=$!
# Stop when done
kill $SPEEDY_PID# Watch logs while testing
tail -f ~/Library/Logs/speedy-delivery.log# Always test in a safe directory first
mkdir ~/test-watch
speedy-delivery ~/test-watch
# Drop test files here first# Run comprehensive tests
make test-clean
# See it in action
make smoke-test
# Check syntax
make lint- Images:
.jpg,.jpeg,.png,.webp,.gif,.heic - Documents:
.pdf
Speedy Delivery uses a simple but effective approach:
- File Watching: Uses
fswatchto monitor directories for new files - Smart Filtering: Only processes supported image and PDF files
- Duplicate Prevention: Caches file timestamps to avoid opening the same file twice
- User Feedback: Plays a sound and opens files in Preview
- Logging: Records all activity for troubleshooting
- fswatch: A powerful tool for cross-platform file system events
- Event filtering: How to filter events to only process relevant files
- Process management: Running background processes and cleanup
- afplay: Playing system sounds programmatically
- open command: Launching applications from the command line
- Preview.app: macOS's default image/PDF viewer
- Error handling: Using
set -eand proper exit codes - Variable quoting: Always quote variables to handle spaces
- Process management: Background processes and signal handling
- Logging: Structured logging with timestamps
- Caching: Simple file-based caching for throttling
- Isolated testing: Using
/tmpdirectories for clean tests - Comprehensive documentation: README, CONTRIBUTING, CHANGELOG
- Development tools: Makefile for common tasks
- Cursor rules: AI-assisted development guidelines
-
"fswatch: command not found"
- Install fswatch using Homebrew:
brew install fswatch
- Install fswatch using Homebrew:
-
Files not opening
- Check the log file:
cat ~/Library/Logs/speedy-delivery.log - Ensure the file types are supported
- Verify file permissions
- Check the log file:
-
Too many files opening
- Increase the
CACHE_TTLvalue in the script - Check if multiple instances are running
- Increase the
To see what's happening in real-time, you can run:
tail -f ~/Library/Logs/speedy-delivery.logPlease see CONTRIBUTING.md for detailed guidelines.
Quick start:
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly:
make test-clean - Commit your changes:
git commit -am 'feat: add feature description' - Push to the branch:
git push origin feature-name - Submit a pull request
See Speedy Delivery in action:
# Clone and test
git clone https://github.com/funkatron/speedy-delivery.git
cd speedy-delivery
make smoke-testThis project is licensed under the MIT License - see the LICENSE file for details.
- Uses
fswatchfor efficient file system monitoring - Inspired by the need for quick image preview workflows
- Built with comprehensive testing and documentation standards