A minimal Linux daemon that watches a Fujitsu ScanSnap S1500 over USB and runs a
script of your choice when its button or paper sensors change. It is the event
trigger in a one-touch scanning workflow; your handler (usually scanimage plus
whatever post-processing you want) performs the scan.
Read the project write-up for the motivation, protocol investigation, and a complete worked example.
s1500d is intentionally narrow. It is a good fit if all of these are true:
- You have a Fujitsu ScanSnap S1500.
- The scanner is connected to a Linux machine (often a headless server).
- You want the physical scan button or paper sensor to launch your own script.
You can confirm the exact model by running lsusb on the Linux machine; an
S1500 appears as ID 04c5:11a2.
s1500d itself does not acquire images or require SANE; it detects hardware
events and invokes your handler. The example scan-to-PDF handler uses SANE's
scanimage, but your handler can run any command you choose.
It is specific to this scanner model rather than a general-purpose tool like scanbd. Other ScanSnap models and macOS/Windows are not currently supported.
- Runs a handler script on scanner events (button press, paper inserted/removed, lid open/close)
- Gesture detection — optional TOML config maps multi-press patterns to named profiles (single press = standard scan, double press = legal size, etc.)
- USB release during handler execution — the daemon releases the USB device before calling your handler, so
scanimageand other SANE tools can claim the scanner --doctormode — interactive hardware verification that walks through each sensor, and says whether the scanner is missing, not permitted, or in use by another program--check-config— validates a config file and its handler without the scanner- Lid detection via USB presence — opening the automatic document feed (ADF) lid powers the scanner on (USB enumeration), closing it powers off (USB disconnect), so door state comes from USB presence rather than the status poll
You can install and confirm event detection before writing a handler or enabling a service.
paru -S s1500dFor Debian/Ubuntu, Fedora, other distributions, or a full systemd deployment, see INSTALL.md.
GitHub releases provide x86-64 deb, rpm, Arch .pkg.tar.zst, and generic tar
packages. The packages deliberately install the service without enabling or
starting it.
Then open the scanner's ADF lid and check the exact USB ID:
lsusb -d 04c5:11a2
s1500d --doctor--doctor interactively checks USB communication, paper detection, and the
scan button. To simply watch events without running anything:
s1500dStop any other scanner-button daemon first; only one process can own the USB interface. Neither command changes your system configuration or starts scans.
If you use Codex, Claude Code, or another coding agent with web access, paste this prompt into it:
Help me evaluate and install https://github.com/mmacpherson/s1500d. First
confirm that this machine runs Linux and that my scanner is exactly a ScanSnap
S1500 (`04c5:11a2`). Read README.md and INSTALL.md, explain the changes you
propose, and get event monitoring working before configuring a scan handler
or enabling the systemd service. Ask before using sudo.
The repository also includes AGENTS.md with project-specific guidance for agents that clone the source.
s1500d Monitor and log events (no handler)
s1500d HANDLER Run HANDLER on each event
s1500d -c CONFIG.toml Gesture detection + profile dispatch
s1500d --doctor Interactive hardware verification
s1500d --check-config FILE Validate a config and its handler (no USB)
This is the complete set of physical scanner actions s1500d recognizes:
| What you do | Raw handler mode | Config mode |
|---|---|---|
| Open the ADF lid | device-arrived |
device-arrived |
| Close the ADF lid | device-left |
device-left |
| Insert paper | paper-in |
paper-in |
| Remove paper | paper-out |
paper-out |
| Press the scan button | button-down |
Starts or continues a multi-press gesture |
| Release the scan button | button-up |
Completes one press and starts the gesture timeout |
In raw mode, the handler receives the event name as $1. In config mode,
button-down and button-up are not sent to the handler. Instead, one or more
complete presses followed by the timeout produce scan <profile> when that
press count appears in [profiles]. Any positive press count can be mapped;
unmapped counts are logged and ignored.
The complete button-gesture behavior in config mode is:
| What you do | What s1500d does |
|---|---|
| Single press | Dispatches the profile mapped to 1 after the timeout |
| Double press | Dispatches the profile mapped to 2 after the timeout |
| Triple press | Dispatches the profile mapped to 3 after the timeout |
| Any higher configured number of presses | Dispatches the profile mapped to that number |
The timeout runs from when s1500d sees each press end; the next press must be seen before it expires. Holding the button longer does not select a different profile. Press at a normal pace: very rapid taps can merge into one press, so a very fast double press may be counted as a single press.
Handlers run one at a time, synchronously, with the USB device released —
including device-arrived. Events observed in the same poll are delivered in
order (paper before button). s1500d cannot see the scanner while a handler
runs: afterwards, a changed button state is delivered as one press or
release (timed when it was seen), paper changes are absorbed (a scan usually
consumes the paper), and a press and release that both happen during the
handler are not seen.
Set log_level = "debug" in your config file for verbose output. The RUST_LOG environment variable overrides config if set.
With -c, s1500d uses a TOML file to map button press counts to named profiles:
handler = "/path/to/your/handler.sh"
gesture_timeout_ms = 600
log_level = "info"
[profiles]
1 = "standard"
2 = "legal"When you press the scan button once, the daemon waits gesture_timeout_ms for additional presses. If none come, it calls handler.sh scan standard. Two presses within the window call handler.sh scan legal. Unmapped press counts are logged and ignored.
Profile names such as standard and legal are arbitrary labels, not built-in
scan presets. Your handler decides what each one means: it can vary simplex or
duplex scanning, color mode, resolution, page size, output format or
destination, post-processing, OCR, upload, or anything else available to the
commands it runs. A handler is not limited to scanimage; it can run any
command you choose.
log_level accepts standard values: off, error, warn, info, debug, trace. The RUST_LOG environment variable overrides this setting if set.
s1500d refuses to start with a config it cannot use: an unknown key, a
gesture_timeout_ms of 0, an unknown log_level, a press count of
0, an empty profile name, or a handler that is missing or not executable.
s1500d --check-config FILE runs the same checks without touching the scanner.
A gesture_timeout_ms outside 100–5000 is allowed but logs a warning.
See contrib/config.toml for a full example and contrib/handler-example.sh for a handler template. For a practical scan-to-PDF workflow, see contrib/handler-scan-to-pdf.sh.
With SCAN_DEVICE unset, the PDF handler runs scanimage -L and selects the
scanner only if exactly one ScanSnap S1500 is listed. Otherwise it reports the
list and asks for an exact SCAN_DEVICE; an explicit value skips discovery.
Discovery runs on every scan. With SANE_CONFIG_DIR unset and a readable
fujitsu.conf, it first tries a temporary Fujitsu-only configuration. Custom
SANE configurations, missing configuration, or failed/empty fast lookups use
full discovery, which can take several seconds. Set SCAN_DEVICE to the logged
name to skip discovery entirely.
It keeps failed attempts in private $SCAN_DIR/.s1500d-*
directories and reports their recovery paths. Completed PDFs are mode 0640,
owned by the invoking account, and never overwrite an existing filename.
See installation and access setup.
The S1500 uses a vendor-specific USB protocol (class FF:FF:FF) with SCSI commands wrapped in a 31-byte Fujitsu envelope. The daemon sends a single GET_HW_STATUS command (SCSI opcode 0xC2) every 100 ms (every 20 ms while waiting for another press of a gesture) and decodes the 12-byte response (checking the 13-byte status reply that follows) to detect button presses and paper presence. State transitions are edge-triggered — the handler fires only when something changes.
The protocol was reverse-engineered from USB captures and the SANE fujitsu backend source code, then empirically verified with a physical scanner using the included docs/explore.py diagnostic tool.
See docs/protocol.md for the full protocol reference.
How this compares to scanbd
scanbd is a general-purpose scanner button daemon. It loads the full SANE stack, opens a connection to the backend, and polls using SANE's option-reading API. For the S1500, this means:
- SANE opens the device, sends ~25 SCSI commands for initialization/capability queries
- Each poll cycle goes through the SANE abstraction layer
- scanbd must coordinate with
scanbmto release/reacquire the SANE connection when scanning
s1500d bypasses SANE entirely:
- Opens the USB device directly via libusb
- Sends one 31-byte command, reads 12 bytes — no initialization sequence
- Releases the raw USB handle before calling your handler, so scanimage/SANE can claim the device cleanly
The tradeoff: s1500d only works with the ScanSnap S1500 (and potentially other ScanSnap models with compatible protocols). scanbd works with any SANE-supported scanner.
The repo includes systemd and udev files in contrib/:
s1500d.service— systemd unit with security hardening70-s1500d.rules— udev rule for non-root USB accessconfig.toml— example configurationhandler-example.sh— example handler scripthandler-scan-to-pdf.sh— scan-to-PDF handler usingscanimage+img2pdf
The packaged service runs as the dedicated s1500d user and sets SCAN_DIR to
/var/lib/s1500d/scans. Package installation does not enable or start it; first
follow INSTALL.md, including the physical-device checks.
Licensed under either of Apache License, Version 2.0 or MIT License at your option. This is the standard dual-license convention used across the Rust ecosystem (rustc, serde, tokio, etc.).