📄 Pdfbar
A macOS menu bar application that monitors your Downloads, Desktop, and iCloud reading directories for PDF and EPUB files, displaying the 15 most recently modified files in a convenient dropdown menu for quick access.
Smart PDF and EPUB file monitoring for your menu bar
Features
- Real-time monitoring - Uses FSEvents to detect new files as they're added
- Smart filtering - Only shows PDF and EPUB files
- Recent files priority - Displays the 15 most recently modified files across all monitored directories
- One-click opening - Click any file in the menu to open it with the default application
- ChatGPT integration - Hold Option (⌥) and click any PDF or EPUB to send it to ChatGPT for analysis
- Lightweight - Runs efficiently in the background as a menu bar-only app
- Multi-directory support - Monitors three key locations:
~/Downloads~/Desktop~/Library/Mobile Documents/com~apple~CloudDocs/reading
- Smart date sorting - Uses last accessed times for reading directory, last modified times for Downloads/Desktop
Installation & Usage
Prebuilt Universal .app (ai.thefocus.pdfbar)
Download PdfBar-<version>.zip from GitHub Releases, move PdfBar.app to /Applications, and clear Gatekeeper quarantine once:
xattr -dr com.apple.quarantine /Applications/PdfBar.app
open /Applications/PdfBar.appRun or Build from Source
# Clone the repository
git clone https://github.com/The-Focus-AI/singlefilemenuapps.git
cd singlefilemenuapps/pdfbar
# Run directly as a Swift script
chmod +x pdfbar.swift
./pdfbar.swift
# Or build the standalone universal PdfBar.app bundle
./build.sh
open PdfBar.appCLI & Debug Flags
./pdfbar.swift --debug
./PdfBar.app/Contents/MacOS/PdfBar --version
./PdfBar.app/Contents/MacOS/PdfBar --dump-menuUsing the Interface
- Menu Bar Icon - Look for the document icon in your menu bar
- Click the Icon - Opens a dropdown showing your 15 most recent PDF/EPUB files
- Select a File - Click any file to open it with the default application
- Send to ChatGPT - Hold Option (⌥) and click any PDF or EPUB to send it to ChatGPT for analysis
- Quit - Use the "Quit" option in the menu to exit
ChatGPT Integration
Pdfbar includes seamless integration with the ChatGPT native app:
- Option + Click on any PDF or EPUB file
- Automatically opens ChatGPT and creates a new chat
- Uploads the selected file for analysis
- Works with files containing spaces and special characters
- Provides fallback options if the primary method fails
Monitored Directories
Pdfbar automatically scans these directories for PDF and EPUB files:
- Downloads - Perfect for recently downloaded documents
- Desktop - For files you're actively working with
- iCloud Reading Folder - For your organized reading collection at
~/Library/Mobile Documents/com~apple~CloudDocs/reading
Technical Details
Requirements
- macOS 10.15+ (Catalina or later)
- Swift 5.0+
- Xcode Command Line Tools (for Swift compilation)
- ChatGPT native app (for ChatGPT integration feature)
File Monitoring
- Uses Apple's FSEvents API for efficient real-time file system monitoring
- Automatically detects file creation, modification, and deletion
- Safe handling of concurrent file operations
- Respects system file access permissions
Performance
- Scans up to 200 files per directory to balance completeness with performance
- Background scanning to avoid blocking the UI
- Efficient memory usage with automatic cleanup of deleted files
- Native macOS integration for optimal responsiveness
Architecture
The application consists of four main components:
- FileMonitor - Handles FSEvents monitoring and file system events
- Pdfbar - Manages the list of recent files and metadata
- MenuManager - Creates and updates the menu bar dropdown interface
- AppDelegate - Coordinates the application lifecycle and initialization
Troubleshooting
Common Issues
App doesn't appear in menu bar
- Check if the app is running:
ps aux | grep pdfbar - Try running from terminal to see error messages
Files not appearing
- Verify the monitored directories exist and are accessible
- Check file permissions on the directories
- Ensure files have
.pdfor.epubextensions
App crashes when clicking files
- Verify files exist and haven't been moved/deleted
- Check that default applications are properly configured for PDF/EPUB files
Logs and Debugging
Pdfbar includes comprehensive logging. When running with --debug, you'll see detailed information about:
- File scanning progress
- Menu updates
- File opening attempts
- FSEvents callback activity
Code Structure
#!/usr/bin/env swift
import Cocoa
import Foundation
import CoreServices
// Main application structure
struct RecentFile {
let path: String
let name: String
let lastModified: Date
let lastAccessed: Date
let sortDate: Date
}
class FileMonitor {
// FSEvents monitoring implementation
}
class Pdfbar {
// File management and menu updates
}
class MenuManager {
// Menu bar interface creation
}
class AppDelegate: NSObject, NSApplicationDelegate {
// Application lifecycle management
}Changelog
v1.1.0
- Added ChatGPT integration
- Option + Click to send PDF/EPUB files to ChatGPT for analysis
- Automatic ChatGPT app activation and new chat creation
- Support for files with spaces and special characters
- Fallback mechanisms for robust operation
v1.0.0
- Initial release
- Real-time file monitoring with FSEvents
- Support for PDF and EPUB files
- Menu bar interface with 15 recent files
- Multi-directory monitoring
- One-click file opening
- Smart date sorting
- Debug mode support