Skip to content

Repository files navigation

Link Farm - Calibre Plugin

A Calibre plugin that creates and manages symlinks from external directories to your Calibre library books, making it easy to sync books to multiple devices with different format preferences.

Features

  • Multiple Sync Profiles: Create named profiles for different devices (e.g., Kindle, Tablet, Phone)
  • Format Preferences: Configure which format to sync per profile (EPUB, MOBI, PDF, etc.)
  • Directory Structure: Choose between flat structure or preserving author subdirectories
  • Manual Sync Control: Sync when you want with a simple toolbar button
  • Automatic Cleanup: Symlinks are automatically removed when books are deselected
  • Visual Indicators: See sync status for each book in your library (planned feature)

Use Case

This plugin is ideal if you:

  • Have a jailbroken Kindle or other device synced via Syncthing, Dropbox, etc.
  • Want to sync different book subsets to different devices
  • Want to sync specific formats to each device
  • Want changes to metadata in Calibre to be reflected in synced copies
  • Want actual symlinks to library files (not copies)

Installation

Method 1: From ZIP file

  1. Download the plugin ZIP file or create it:

    cd /path/to/calibre_link_farm
    zip -r linkfarm.zip * -x "*.pyc" -x "__pycache__/*" -x ".git/*"
  2. In Calibre, go to Preferences → Plugins → Load plugin from file

  3. Select the linkfarm.zip file

  4. Restart Calibre

Method 2: Development Mode

For development/testing, you can create a symlink to this directory in Calibre's plugin directory:

# Find your Calibre plugin directory
# Usually: ~/.config/calibre/plugins/

# Create symlink
ln -s /path/to/calibre_link_farm ~/.config/calibre/plugins/linkfarm

Then restart Calibre.

Setup

1. Custom Column (Automatic)

The plugin automatically creates the custom column on first use!

When you first start Calibre after installing the plugin, it will automatically create a custom column called #sync_profiles (Yes/No type) to track which books to sync.

If automatic creation fails (due to permissions), the plugin will show clear instructions on how to create it manually:

  1. Go to Preferences → Add your own columns
  2. Click Add custom column
  3. Configure:
    • Lookup name: sync_profiles
    • Column heading: Sync
    • Column type: Yes/No
  4. Click OK

Alternative: You can use tags instead (configure in plugin settings).

2. Configure Plugin

  1. Go to Preferences → Plugins → User Interface Actions → Link Farm
  2. Click Customize plugin
  3. In General Settings:
    • Verify the custom column name matches what you created
    • Configure other preferences as desired

3. Create Sync Profiles

  1. In the plugin configuration dialog, click New Profile
  2. Configure:
    • Profile Name: e.g., "Kindle", "Tablet"
    • Target Directory: Where symlinks should be created (e.g., /home/user/kindle-sync)
    • Format Priority: Drag formats to reorder preference (top = highest priority)
    • Directory Structure: Choose flat or preserve author subdirectories
    • Enable this profile: Check to activate
  3. Click Save
  4. Repeat for additional devices/profiles

Usage

Selecting Books for Sync

  1. In your Calibre library, check the custom column (e.g., Sync) for books you want to sync
  2. For bulk operations:
    • Select multiple books
    • Right-click the custom column header
    • Set value for all selected books

Syncing Books

Sync All Profiles

  1. Click the Link Farm toolbar button
  2. Select Sync All Active Profiles
  3. Review the results dialog

Sync Single Profile

  1. Click the Link Farm toolbar button
  2. Select Sync: [Profile Name]
  3. Review the results dialog

What Happens During Sync

For each active profile:

  1. Format Selection: Plugin selects the best available format based on your priority list
  2. Path Computation: Determines target path (flat or structured)
  3. Symlink Creation: Creates symlinks for newly selected books
  4. Symlink Updates: Updates symlinks if source changed
  5. Symlink Removal: Removes symlinks for deselected books
  6. State Tracking: Saves sync status for each book/profile

Directory Structure Options

Flat Structure

All books are placed directly in the target directory:

/sync-dir/
├── Book Title 1.epub
├── Book Title 2.mobi
└── Book Title 3.pdf

Preserve Author Subdirectories

Books are organized by author:

/sync-dir/
├── Author Name 1/
│   ├── Book Title 1.epub
│   └── Book Title 2.epub
└── Author Name 2/
    └── Book Title 3.mobi

Format Priority

The plugin selects formats based on your priority list. For example, with priority [MOBI, EPUB, PDF]:

  • Book has EPUB and PDF → Syncs as EPUB (not MOBI, so use next: EPUB)
  • Book has MOBI, EPUB, and PDF → Syncs as MOBI (highest priority available)
  • Book has only PDF → Syncs as PDF (only format available)
  • Book has no formats → Skipped

Troubleshooting

Plugin doesn't appear in toolbar

  • Restart Calibre after installation
  • Check Preferences → Toolbars to ensure plugin is enabled
  • Check Calibre's debug log for errors

"Target directory is not accessible" error

  • Verify the directory exists and you have write permissions
  • For network locations, ensure they're mounted
  • Create the directory manually if it doesn't exist

Symlinks not being created

  • Linux/macOS: Should work by default
  • Windows: Requires either:
    • Administrator privileges, OR
    • Developer Mode enabled (Windows 10+)
    • Alternative: Plugin could be modified to use hard links or file copies

Books not appearing in sync

  • Verify the custom column is checked for those books
  • Check that the profile is enabled (active checkbox)
  • Ensure books have at least one format in the priority list
  • Check sync results dialog for errors

Metadata changes not reflecting

Symlinks point to the actual files in your Calibre library, so metadata changes in Calibre will be reflected immediately in the synced files (since they're the same files).

However, if you're syncing metadata files separately, you'll need to re-sync after metadata changes.

Platform-Specific Notes

Linux

Works out of the box. Symlinks are fully supported.

macOS

Works out of the box. Symlinks are fully supported.

Windows

Symlink Requirements:

  • Windows 10/11: Enable Developer Mode, OR run Calibre as Administrator
  • Older Windows: Run Calibre as Administrator

Alternative Solutions (requires plugin modification):

  • Use hard links instead (limited to same drive)
  • Use directory junctions
  • Copy files instead of symlinking

To enable Developer Mode on Windows 10/11:

  1. Settings → Update & Security → For Developers
  2. Enable "Developer Mode"
  3. Restart Calibre

Advanced Usage

Using Tags Instead of Custom Column

  1. In plugin settings, select Tags as the selection method
  2. Set a tag prefix (e.g., sync:)
  3. Tag books with sync:ProfileName to sync them to that profile
    • Example: sync:Kindle, sync:Tablet

Multiple Profiles for Same Book

A book can be synced to multiple profiles simultaneously:

  • Each profile creates its own symlink
  • Different formats can be synced to different profiles
  • Removing a book from one profile doesn't affect others

Automating Sync

Currently, sync is manual only. Future versions may add:

  • Auto-sync on book addition/modification
  • Watch mode
  • Command-line interface for scripting

File Structure

calibre_link_farm/
├── __init__.py              # Plugin registration
├── action.py                # Main interface action
├── config.py                # Configuration dialog
├── sync_engine.py           # Core sync logic
├── profile_manager.py       # Profile management
├── dialogs.py               # GUI dialogs
├── common.py                # Shared utilities
├── create_icons.py          # Icon generation script
├── plugin-import-name-linkfarm.txt  # Import marker
├── images/                  # Plugin icons
│   ├── icon.png
│   ├── synced.png
│   ├── pending.png
│   └── error.png
└── README.md                # This file

Technical Details

Sync State Storage

The plugin stores sync state using Calibre's custom book data API. This includes:

  • Sync status per book/profile
  • Symlink path
  • Target format
  • Last sync timestamp
  • Error messages (if any)

Performance

  • Efficient for large libraries (10,000+ books)
  • Only scans selected books during sync
  • Uses incremental updates (doesn't recreate unchanged symlinks)
  • Minimal database operations

Safety

  • Never modifies library files
  • Creates symlinks only (no copying or moving)
  • Validates all operations before execution
  • Provides detailed error messages

FAQ

Q: Can I sync the same book in different formats to different devices? A: Yes! Each profile has its own format priority, so you can sync MOBI to your Kindle profile and EPUB to your tablet profile.

Q: What happens if I delete a book from Calibre? A: The symlinks will become broken. The next sync will detect and remove them automatically.

Q: Can I manually delete symlinks? A: Yes, but the plugin won't know about it until the next sync. It's better to deselect the book in Calibre and sync.

Q: Does this work with Calibre Content Server? A: This plugin is independent of the Content Server. It creates local symlinks for syncing via file sync tools (Syncthing, Dropbox, etc.).

Q: Can I change the target directory after syncing? A: Yes, but you should:

  1. Edit the profile and change the directory
  2. Sync again (this creates new symlinks in the new location)
  3. Manually delete the old directory if desired

Limitations

  • Windows symlinks: Require administrator privileges or Developer Mode
  • Cross-drive symlinks: Not supported on all platforms (use same drive)
  • Network paths: May have permission or performance issues
  • Visual indicators: Not yet implemented (planned feature)

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly with Calibre
  5. Submit a pull request

License

GPL v3 - See LICENSE file for details

Support

For issues, questions, or feature requests:

  • Open an issue on GitHub
  • Include Calibre version, OS, and error messages
  • Attach debug log if applicable (Preferences → Miscellaneous → Enable debug output)

Changelog

Version 1.0.0 (2025-12-23)

  • Initial release
  • Multiple sync profiles
  • Format preferences
  • Flat and structured directory options
  • Manual sync control
  • Automatic symlink cleanup
  • Configuration dialog
  • Profile management

Credits

Created by the Link Farm Contributors

Related Projects


Happy Syncing! 📚🔗

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages