zathura
zathura 是一个基于命令行的 PDF 查看工具,可以用作 Yazi 和 NeoMutt 的扩展工具。
配置文件
The customization of zathura is be managed via a configuration file called zathurarc. By default zathura will evaluate the following files:
/etc/zathurarc$XDG_CONFIG_HOME/zathura/zathurarc(default:~/.config/zathura/zathurarc)
The zathurarc file is a simple plain text file that can be populated with various commands to change the behavior and the look of zathura which we are going to describe in the following subsections. Each line (besides empty lines and comments which start with a prepended #) is evaluated on its own, so it is not possible to write multiple commands in one single line.
复制文本
有时候,我们希望从 PDF 文件内复制一些信息,比如从一些 UPS shipping labels 上获取 tracking number,然后在浏览器上通过官网提供的界面进行轨迹查询。
注意
经过图片转换的 PDF 通常是无法提取文本的。只有经过文本文档转换过来的 PDF 才更容易提取文字。
如果没有事先进行配置,在 zathura 的查看界面,通过鼠标左键点击、拖动可以高亮文本,底部状态栏显示内容已经复制的提示信息:
Copied selected text to selection primary: Sound Rise II官方文档说,这时文本已经复制至 PRIMARY 剪贴板,在其他的编辑应用内按下鼠标中键,可以粘贴。但是我的鼠标不行。
打开配置文件,添加:
# Change the X clipboard from PRIMARY to CLIPBOARD
set selection-clipboard clipboard这时再通过鼠标左键点击、拖动、高亮文本,底部状态栏显示内容已经复制至系统剪贴板的提示信息:
Copied selected text to selection clipboard: Sound Rise II去到其他的编辑应用,按下 Ctrl + V 就可正常粘贴了。
中文乱码
亚马逊 FBA 贴纸内包含中文的发货地址,在其他的查看器可以正常显示,在 zathura 查看却是乱码。这说明内置的编解码器出现了异常。
完全黑屏
有发现在 NeoMutt 内查看某些 PDF 格式的附件,打开之后呈完全黑屏状态。
MEMO: Fixing Zathura PDF Plugin After Homebrew Upgrade
Date: February 24, 2026
Subject: Restoring Zathura PDF viewing capability after brew upgrade
Issue Overview
After running brew upgrade, Zathura fails to open PDF files with error:
warning: Found no plugins. Please install at least one plugin.
error: Could not determine file type.Cause: The plugin symlink at /opt/homebrew/opt/zathura/lib/zathura/libpdf-poppler.dylib points to an old version number in the Cellar path that no longer exists after upgrade.
Quick Fix Steps (2 minutes)
Step 1: Find the new plugin location
find /opt/homebrew/Cellar -name "*pdf-poppler*" -type f 2>/dev/null | grep dylibExpected output: /opt/homebrew/Cellar/zathura-pdf-poppler/[NEW_VERSION]/libpdf-poppler.dylib
Step 2: Recreate the symlink
# Remove old symlink (if exists)
rm -f /opt/homebrew/opt/zathura/lib/zathura/libpdf-poppler.dylib
# Create new symlink with correct version
ln -s /opt/homebrew/Cellar/zathura-pdf-poppler/[NEW_VERSION]/libpdf-poppler.dylib /opt/homebrew/opt/zathura/lib/zathura/libpdf-poppler.dylibStep 3: Verify
# Check symlink is valid
ls -la /opt/homebrew/opt/zathura/lib/zathura/
# Should show: libpdf-poppler.dylib -> /opt/homebrew/Cellar/zathura-pdf-poppler/[NEW_VERSION]/libpdf-poppler.dylib
# Test PDF opening
zathura ~/test.pdfAlternative: Version-Agnostic Fix (Recommended)
Use the opt path which always points to current version:
ln -sf /opt/homebrew/opt/zathura-pdf-poppler/libpdf-poppler.dylib /opt/homebrew/opt/zathura/lib/zathura/libpdf-poppler.dylibVerification Checklist
- Zathura opens PDFs from terminal
- NeoMutt can open PDF attachments
- DBus synctex still works (Ctrl+Click in PDF jumps to editor)
Background Context
- Zathura and its PDF plugin are installed from
zegervdv/zathuratap - Plugin path includes version number in Cellar:
/opt/homebrew/Cellar/zathura-pdf-poppler/[VERSION]/libpdf-poppler.dylib - Zathura expects plugin at:
/opt/homebrew/opt/zathura/lib/zathura/libpdf-poppler.dylib brew upgradeupdates the version number, breaking the symlink- DBus configuration, mailcap, and mutt settings remain intact
Prevention Note
Consider using the version-agnostic symlink (Alternative fix above) to prevent this issue in future upgrades.
Zathura on macOS: Potential Pitfalls and Debugging Guide
Based on our extensive troubleshooting session, here are the critical failure points for Zathura on macOS, ranked by likelihood and impact.
1. Plugin Symlink Breakage (Most Common)
The Problem: After brew upgrade, the plugin symlink points to a non-existent version in Cellar, causing:
warning: Found no plugins. Please install at least one plugin.
error: Could not determine file type.Why It Happens:
- Zathura expects plugins at:
/opt/homebrew/opt/zathura/lib/zathura/ - Plugin is actually at:
/opt/homebrew/Cellar/zathura-pdf-poppler/[VERSION]/libpdf-poppler.dylib brew upgradechanges the version number, breaking the symlink
Crucial Debugging Points:
# Check if symlink exists and where it points
ls -la /opt/homebrew/opt/zathura/lib/zathura/
# Find the actual plugin location
find /opt/homebrew/Cellar -name "*pdf-poppler*" -type f | grep dylib
# Test if Zathura can find plugins
zathura -l # List available pluginsThe Fix:
ln -sf /opt/homebrew/Cellar/zathura-pdf-poppler/[CURRENT_VERSION]/libpdf-poppler.dylib /opt/homebrew/opt/zathura/lib/zathura/libpdf-poppler.dylib2. D-Bus Configuration Syntax Error
The Problem: Incorrect syntax in session.conf prevents D-Bus from starting:
dbus[7105]: Failed to start message bus: Attribute "allow_anonymous" is invalid on <auth> element in this contextWhy It Happens:
- The
allow_anonymous="yes"attribute belongs on a standalone<allow_anonymous/>element, not on the<auth>tag - Users often incorrectly modify the authentication section
Crucial Debugging Points:
# Check if D-Bus is actually running
ps aux | grep dbus-daemon | grep -v grep
# Check for startup errors
cat /tmp/dbus-session.log
# Validate the config file syntax
grep -n "allow_anonymous" /opt/homebrew/opt/dbus/share/dbus-1/session.confCorrect Configuration (around line 260):
<auth>DBUS_COOKIE_SHA1</auth>
<auth>EXTERNAL</auth>
<!-- <allow_anonymous/> --> <!-- Standalone tag, not on <auth> -->3. Missing or Incorrect DBUS_SESSION_BUS_ADDRESS
The Problem: Zathura can't communicate with D-Bus for SyncTeX functionality, but basic PDF viewing still works.
Why It Happens:
- Environment variable not set in shell
- Session socket doesn't exist or has wrong permissions
- Launch agent not properly loaded
Crucial Debugging Points:
# Check if socket exists and is valid
ls -la ~/.cache/dbus/session
file ~/.cache/dbus/session # Should show "socket"
# Check current environment variable
echo $DBUS_SESSION_BUS_ADDRESS
# Test D-Bus communication
dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
# Check launch agent status
launchctl list | grep dbusThe Fix:
export DBUS_SESSION_BUS_ADDRESS="unix:path=$HOME/.cache/dbus/session"
# Add to ~/.zshrc for persistence4. Launch Agent Not Loading Properly
The Problem: D-Bus doesn't start automatically at login, even though brew services claims it's loaded.
Why It Happens:
- Homebrew's service tracking doesn't play well with
launchd-managed services - The plist file may have incorrect paths or environment variables
$HOMEexpansion issues in plist files
Crucial Debugging Points:
# Check if plist exists and is valid
ls -la ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
plutil -lint ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
# Manual load/unload test
launchctl unload ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
launchctl load ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
# Check launchd status
launchctl list | grep dbusCommon Plist Issue:
<!-- DON'T use $HOME in plist -->
<string>--address=unix:path=$HOME/.cache/dbus/session</string>
<!-- DO use absolute path -->
<string>--address=unix:path=/Users/username/.cache/dbus/session</string>5. brew services False Negatives
The Problem:
❯ brew services info dbus
Running: ✘
Loaded: ✔
Schedulable: ✘Why It Happens:
- Homebrew's service tracker looks for processes by specific PID patterns
- D-Bus runs under
launchdand doesn't match Homebrew's detection criteria - This is a cosmetic issue, not a functional one
Crucial Debugging Points (to confirm it's actually working):
# THIS shows actual running process (reliable)
ps aux | grep dbus-daemon | grep -v grep
# THIS shows launchd registration (reliable)
launchctl list | grep dbus
# THIS shows socket accessibility (reliable)
launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET
# THIS tests actual functionality (most reliable)
dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNamesThe Truth: If dbus-send works and you have a running process, ignore brew services info completely.
6. Environment Cleanliness When Launched from GUI Apps
The Problem: Zathura works from terminal but fails when launched from NeoMutt, Finder, or other GUI apps.
Why It Happens:
- GUI apps inherit a minimal environment, missing shell settings
DBUS_SESSION_BUS_ADDRESSnot setPATHmay not include Homebrew directories
Crucial Debugging Points:
# Create a test script to see what environment GUI apps see
cat > ~/env-test << 'EOF'
#!/bin/zsh
echo "PATH: $PATH" > /tmp/gui-env.log
echo "DBUS: $DBUS_SESSION_BUS_ADDRESS" >> /tmp/gui-env.log
env >> /tmp/gui-env.log
EOF
chmod +x ~/env-test
# Then associate this with a file type in mailcap temporarilyThe Fix (Wrapper Script):
#!/bin/zsh
export ZATHURA_PLUGINS_PATH=/opt/homebrew/opt/zathura/lib/zathura
export DBUS_SESSION_BUS_ADDRESS="unix:path=$HOME/.cache/dbus/session"
exec /opt/homebrew/bin/zathura "$@"7. SyncTeX Feature Not Built Into Zathura
The Problem: Zathura doesn't respond to SyncTeX commands or show "Built without synctex support" errors.
Why It Happens:
- Zathura must be compiled with
--with-synctexflag - Pre-built bottles may not include SyncTeX support
- Installation from
zegervdv/zathuratap may need HEAD build
Crucial Debugging Points:
# Check if binary has synctex symbols
strings $(which zathura) | grep -i synctex | head -10
# If output shows "Built without synctex support", you need to reinstall
brew reinstall zegervdv/zathura/zathura --HEAD --with-synctexQuick Reference: Diagnostic Command Cheat Sheet
Plugin - Symlink validity
bashls -la /opt/homebrew/opt/zathura/lib/zathura/Plugin - Actual location
bashfind /opt/homebrew/Cellar -name "*pdf-poppler*" | grep dylibD-Bus - Process running
bashps aux | grep dbus-daemon | grep -v grepD-Bus - Socket exists
bashls -la ~/.cache/dbus/sessionD-Bus - Functionality
bashdbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNamesD-Bus - Launch agent
bashlaunchctl list | grep dbusD-Bus - Config syntax
bashgrep -n "allow_anonymous" /opt/homebrew/opt/dbus/share/dbus-1/session.confSyncTeX - Feature support
bashstrings $(which zathura) | grep -i synctexEnvironment - Current setting
bashecho $DBUS_SESSION_BUS_ADDRESS
Summary: The Three Critical Components
- Plugin Symlink - Without this, Zathura can't open any PDFs
- D-Bus Running - Without this, Zathura loses SyncTeX functionality
- D-Bus Config Syntax - Without correct syntax, D-Bus won't start at all
The plugin symlink is the most frequent failure point after brew upgrade. The D-Bus configuration is the most subtle because errors only appear in logs, not in obvious UI messages.