- Features
- Installation
- Usage
- Configuration
- Extensions
- Frequently Asked Questions (FAQ)
- Contribution
- Support
- Multiple Launcher Support: Browse with
fzf,rofi, orgum, all supporting rich previews. - Deep Calibre Integration: Interface securely with your library via
calibredb. - Search & Filter: Search books using Calibre's native syntax, or browse directly by Authors, Series, Tags, Formats, Languages, Ratings, Publishers, and Identifiers.
- Personal Reading Lists: Track your reading journey with built-in user lists (Reading, Paused, Planning, Re-reading, Completed, Dropped, Docs).
- Extensive Book Actions: Directly from the terminal:
- Read your books
- Edit Metadata (Tags, Authors, Dates, etc.)
- Convert formats (
ebook-convert) - Polish books (
ebook-polish) - View raw metadata
- Open in Calibre's GUI Viewer (
ebook-viewer)
- Bulk Add Books: Seamlessly add books from files or folders (integrates with
fzforyazias a file chooser). - Theming & Styling: Theming support through
.themeextensions with Tokyo Night as the default theme. - Multi-language Support: Loadable language files (
.lang) to localize UI prompts and messages. - Cover Art Previews: High-quality book cover image rendering directly in the terminal using
chafa,icat, orimgcat. - Custom Readers: Map specific formats (e.g., EPUB, PDF) to your preferred CLI/GUI reading apps.
- Scriptable Shortcuts: Bypass menus and jump straight to specific lists, searches, or actions using direct command-line flags.
- Stateful Sub-Shell Execution: Drop into a shell pre-loaded with environment variables of your currently selected book for custom scripting or manual database interactions.
- Desktop Integration: Generate a
.desktopfile to launch natively from application menus (Linux). - Cache Management: Automatically caches your Calibre database as JSON for lightning-fast speeds, cleaning up stale previews and data automatically (Default: 7 days).
- OS Support: Works across Linux, macOS, Windows (via WSL/MSYS/Cygwin), and Android (Termux).
- Auto-Updater: Secure update checker that pulls the latest version from GitHub and shows you the diff before applying.
- Shell Completions: Includes tab completions for
fish,bash, andzshcovering flags, custom categories, and book sorting options.
Required:
calibre- Providescalibredbfor database interactions.fzf- Main terminal launcher.jq- For rapid JSON database parsing.sh- Any POSIX-compliant shell (Bash, Zsh, Dash, etc.).- Nerd Font - For the icons (Recommended: JetBrains Mono Nerd Font).
Optional (Highly Recommended for Full Functionality):
- Terminal File Explorers (For adding books):
yaziorfzf - Calibre CLI Tools:
ebook-convert,ebook-polish,ebook-viewer,ebook-meta,ebook-edit(Usually bundled with Calibre). - Alternate Launchers:
rofi(for a desktop app experience) orgum(for styled TUI flows). - Modern Terminal That Supports True Color:
kitty,ghostty,wezterm, etc. - Terminal Image Viewers (For Cover Art):
chafa(Cross-terminal)icat(Recommended for Kitty and Ghostty)imgcat(For iTerm2/WezTerm)
- Terminal QoL:
bat(Better paging and diff viewing)
Ensure ~/.local/bin exists and is added to your system's $PATH.
curl -sL "https://github.com/Benexl/lib-x/releases/download/v0.5.0/lib-x" -o ~/.local/bin/lib-x
chmod +x ~/.local/bin/lib-xTo uninstall, just run: rm ~/.local/bin/lib-x, then to remove its related data folders rm -r ~/.config/lib-x and rm -r ~/.cache/lib-x.
Note: I am not the one who maintains any of these packages and you should probably turn off auto updates in lib-x if using them.
Arch Linux (AUR)
yay -S lib-x-git
# or if you prefer paru
paru -S lib-x-gitNix / NixOS
1. Imperative:
nix profile install github:Benexl/lib-x2. Declarative:
First, add the repository to your flake.nix inputs:
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
lib-x = {
url = "github:Benexl/lib-x";
inputs.nixpkgs.follows = "nixpkgs";
};
}-
For system-wide installation (in
configuration.nix):environment.systemPackages = [ inputs.lib-x.packages."${system}".default ];
-
For user-level installation (via Home Manager in
home.nix):home.packages = [ inputs.lib-x.packages."${system}".default ];
You can opt to either use it via interactive menus or command-line shortcuts for scripting and keybinding.
lib-x [OPTIONS]
lib-x completions [--fish | --bash | --zsh | --help]To launch the interactive terminal interface with your default settings, run:
lib-x-s, --search <term>: Prompt for (or immediately execute) a book search.-S, --sort-by <field>: Sort the books by a specific field (e.g.,author,size,timestamp). Append_ascfor ascending order (default is descending).-r, --no-of-random-books <num>: Display a specific number of random books from your library.
All these options can be paired with --cmd-exit (-ce) so that backing out of the menu exits the CLI entirely.
--reading-list: Open your actively reading list.--recent: Show recently opened books.--paused: Open paused books.--rereading: Open books marked for re-reading.--planning: Open planned/to-read books.--completed: Open completed books.--docs: Open your documents list.--dropped: Open dropped/abandoned books.--all: Browse your entire Calibre library directly.--misc: Open the miscellaneous menu (Sync, Add books).
Can be paired with --book-skip (-bs) to auto-select the first result, and --book-exit (-be) to exit immediately after the action.
--read: Open the selected book in your preferred reader.--edit-metadata: Start editing the metadata for a book.--remove-book: Delete a book from the library.--viewer: Open in the Calibre GUI ebook-viewer.--convert: Convert the book to another format.--edit-book: Open in the Calibre eBook Editor.--polish: Runebook-polishon the selected book.--show-metadata: View the raw metadata (usingebook-meta).
-l, --launcher <fzf|rofi|gum>: Override the default menu launcher.--preview: Enable the preview window (metadata).--no-preview: Disable the preview window.--preview-images: Enable the image preview (book covers).--no-preview-images: Disable the image preview.-d, --disown-reading-process: Detach the reading process from the terminal (default).-D, --no-disown-reading-process: Keep the reading process attached to the terminal session.--private: Do not update the recent history list when opening a book.
Note: You can find preconfigured rofi themes in the GitHub repo to elevate the desktop app experience!
--rofi-theme-main <path>--rofi-theme-preview <path>--rofi-theme-prompt <path>--rofi-theme-confirm <path>--rofi-theme-pager <path>
-x, --extension <ext>: Load a specific extension file.-xargs, --extension-arguments <args>: Pass arguments to a loaded extension.-e, --edit-config: Open thelib-xconfiguration file in your$EDITOR.-U, --update: Check for and apply the latest script update from GitHub.-E, --generate-desktop-entry: Print a.desktopapplication entry tostdout.-v, --version: Print version information and exit.-h, --help: Show the help message and exit.--config-write: Write the current runtime config to the config file.
Almost all CLI options can be permanently set in ~/.config/lib-x/config or overridden using environment variables.
LIB_X_LAUNCHER(e.g.,fzf,rofi,gum)LIB_X_CALIBRE_LIBRARY_PATH(e.g.,$HOME/Documents/Calibre Library)LIB_X_PREVIEW_ENABLE(trueorfalse)LIB_X_PREVIEW_IMAGES_ENABLE(trueorfalse)LIB_X_PREVIEW_IMAGES_RENDERER(chafa,icat,imgcat)LIB_X_FILE_EXPLORER(fzf,yazi)
Hello world (Save config)
# always put --config-write at the end to save the runtime config
LIB_X_PREVIEW_IMAGES_RENDERER=icat lib-x --preview --preview-images --config-writeDesktop App Launcher
Launch lib-x as a graphical application using Rofi (great with keybindings!).
lib-x --launcher rofi --preview --preview-images --disown-reading-processCustom Book Reader Mapping
You want EPUBs to open in zathura and PDFs to open in evince. Set this in your config or env:
LIB_X_READER="epub:zathura,pdf:evince" lib-x --readJump straight to your current reads
lib-x --reading-list --cmd-exitFind a specific author and exit menu on back
lib-x -s "Isaac Asimov" --cmd-exitCreate a desktop entry
lib-x -E > ~/.local/share/applications/lib-x.desktopShell completions (Fish)
lib-x completions --fish > ~/.config/fish/completions/lib-x.fishBy default, the main configuration file is located at:
~/.config/lib-x/config(Note: It respects the $XDG_CONFIG_HOME environment variable if set).
You can open it directly using the CLI:
lib-x --edit-config| Variable | Default | Description |
|---|---|---|
CONFIG_LAUNCHER |
fzf |
The menu launcher tool to use. Options: fzf, rofi, gum. |
CONFIG_COLORS_ENABLE |
true |
Enable or disable ANSI true-color (24-bit) formatting in the UI. |
CONFIG_EDITOR |
vi (or $EDITOR) |
Text editor used for editing config files, histories, and metadata. |
CONFIG_NOTIFICATION_DURATION |
3 |
Duration (in seconds) for desktop/CLI notifications to remain visible. |
CONFIG_TERMINAL_EXEC |
auto-detected | The terminal emulator used to launch external interactive shell tools. |
| Variable | Default | Description |
|---|---|---|
CONFIG_PREVIEW_ENABLE |
false |
Enable or disable the preview window (metadata descriptions). |
CONFIG_PREVIEW_IMAGES_ENABLE |
false |
Enable rendering book covers in the preview window. |
CONFIG_PREVIEW_IMAGES_RENDERER |
chafa |
Tool used to render images in the terminal. Options: chafa, icat, imgcat. |
CONFIG_PREVIEW_IMAGES_CHAFA_ARGS |
"" |
Pass custom arguments to chafa. |
CONFIG_PREVIEW_IMAGES_ICAT_ARGS |
"" |
Pass custom arguments to icat / kitty +kitten icat. |
| Variable | Default | Description |
|---|---|---|
CONFIG_CALIBRE_LIBRARY_PATH |
~/Calibre Library |
Absolute path to your Calibre library database directory. |
CONFIG_FILE_EXPLORER |
fzf |
File chooser used when adding books to the library. Options: fzf, yazi. |
CONFIG_READER |
"" |
Mapping of ext:command (e.g. epub:zathura). Falls back to OS default if empty. |
CONFIG_READING_PROCESS_DISOWN |
true |
Detach reader process from terminal so lib-x can be closed without killing app. |
CONFIG_SORT_BY |
"" |
Default sort field (e.g. author, size_asc, pubdate). |
CONFIG_RANDOM_BOOKS_LIMIT |
30 |
Number of books to return when selecting "Random". |
| Variable | Default | Description |
|---|---|---|
CONFIG_SEARCH_HISTORY_ENABLE |
true |
Save local search history to track and quickly recall past queries. |
CONFIG_RECENT_BOOKS_UPDATE |
true |
Automatically log opened books to the "Recent" list. |
CONFIG_RECENT_BOOKS_LIMIT |
30 |
Number of books to keep in the recent history list. |
CONFIG_CACHE_RETENTION_DAYS |
7 |
Auto-clean stale preview images and shell scripts older than this duration. |
(Note: Advanced Fzf and Gum styling parameters are also exposed in the config file. See the generated config file for full default strings).
| Variable | Default | Description |
|---|---|---|
CONFIG_FZF_HEADER |
(logo) | Custom ASCII logo displayed at the top of the fzf menu. |
CONFIG_FZF_OPTS |
(see config) | Fine‑tune fzf layout, colors, and bindings. Defaults to "Tokyo Night". |
CONFIG_ROFI_THEME_MAIN |
"" |
Path to a custom Rofi .rasi theme for the main menu. |
CONFIG_ROFI_THEME_PREVIEW |
"" |
Path to a custom Rofi .rasi theme for the preview menu. |
CONFIG_ROFI_THEME_PROMPT |
"" |
Path to a custom Rofi .rasi theme for prompt dialogs. |
CONFIG_ROFI_THEME_CONFIRM |
"" |
Path to a custom Rofi .rasi theme for confirmation dialogs. |
CONFIG_ROFI_THEME_PAGER |
"" |
Path to a custom Rofi .rasi theme for the pager. |
lib-x supports extensions to add languages, themes, or override functionality.
Extensions are standard shell scripts loaded from ~/.config/lib-x/extensions/.
- Languages: Add localizations by editing
langs/default.lang(e.g., swap outTXT_MENU_MAIN_SEARCH="Search"to your native language). - Themes: Tweak terminal colors by editing
themes/default.theme(defines$THEME_HEADER_COLOR,$THEME_FZF_ICON_COLOR_PRIMARY, etc.). - Autoloading: Add any custom
.shscript names toCONFIG_AUTOLOADED_EXTENSIONS="custom.sh"to have them sourced at runtime.
Reporting Bugs
lib-x is a wrapper around the powerful calibredb command-line utility.
Before opening an issue, check if the underlying issue is Calibre related:
- Database syncing / Book adding fails: Ensure
calibredbworks directly from your terminal. - Metadata parsing or navigation logic fails: This is handled by
lib-x. Please open an issue!
Where is my Calibre Database located?
By default, lib-x looks in ~/Calibre Library. If your library is elsewhere, change the CONFIG_CALIBRE_LIBRARY_PATH variable in your config file (via lib-x -e).
The script specifically looks for the metadata.db file in this directory to track modifications.
How do I read EPUBs or PDFs in specific apps?
By default, lib-x uses your OS's default file opener (xdg-open, open, etc.).
If you want to enforce specific readers, use the CONFIG_READER variable formatted as extension:command,extension2:command2.
Example: CONFIG_READER="epub:zathura,pdf:evince,mobi:foliate"
Why are my book covers (image previews) not showing up?
Image previews require a few components to work together:
- Ensure you have enabled them in your config:
CONFIG_PREVIEW_ENABLE=trueandCONFIG_PREVIEW_IMAGES_ENABLE=true. - Ensure you have a supported image renderer installed (e.g.,
chafa,icat, orimgcat). - Set the correct renderer in your config:
CONFIG_PREVIEW_IMAGES_RENDERER="chafa". - Ensure your terminal emulator actually supports image rendering. If it doesn't,
chafais highly recommended as it falls back to excellent ASCII/block character rendering.
What is the `--shell` action in the Book Actions menu?
Selecting Shell from a book's action menu drops you into a subshell pre-loaded with all the data about that book.
Variables exported include:
STATE_CURRENT_BOOK_TITLESTATE_CURRENT_BOOK(Raw JSON payload containing UUIDs, authors, formats, tags)CALIBRE_DB_JSON_FILE(Path to the cached database)
This is incredibly powerful if you want to run custom scripts, write raw Calibre commands, or manipulate the book file manually without leaving lib-x. Use jq to parse the $STATE_CURRENT_BOOK payload.
How does "Add Books from Folder" work with Yazi?
If you have yazi installed and set CONFIG_FILE_EXPLORER="yazi", selecting "Add Books From Folder" (in the Miscellaneous menu) will launch yazi.
Navigate to the directory you want to import, press ENTER, and lib-x will automatically pass that directory to calibredb add along with any custom options you specify in the subsequent prompt.
How do I customize the Nerd Font icons?
All icons are defined in the language variables (TXT_ICON_MENU_MAIN_SEARCH, TXT_ICON_MENU_BOOK_ACTIONS_READ, etc.).
If you don't like them or your terminal doesn't support Nerd Fonts, create a custom .lang extension in ~/.config/lib-x/extensions/langs/ and override these variables with empty strings or standard ASCII characters. Load it via CONFIG_AUTOLOADED_EXTENSIONS.
Pull requests are highly welcome! :)
If you enjoy using lib-x and want to support its ongoing development, consider leaving a Star on GitHub!