Skip to content

Instantly share code, notes, and snippets.

@fehlfarbe
Created February 22, 2025 15:15
Show Gist options
  • Select an option

  • Save fehlfarbe/a973f2b3b9857db8e3566923cf8848fb to your computer and use it in GitHub Desktop.

Select an option

Save fehlfarbe/a973f2b3b9857db8e3566923cf8848fb to your computer and use it in GitHub Desktop.
scanbd config for Canon DR-M140 scanner
/*
* $Id: scanbd.conf 241 2017-04-19 07:53:25Z wimalopaan $
*
* scanbd - KMUX scanner button daemon
*
* Copyright (C) 2008 - 2017 Wilhelm Meier (wilhelm.wm.meier@googlemail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# global settings
global {
# turn on debugging
# log to console
debug = true
# debug logging
# 1=error, 2=warn, 3=info, 4-7=debug
debug-level = 2
# drop priviliges to this user
#=============================
# Linux (most distributions use the saned user):
# user = saned
# ArchLinux (ArchLinux doesn't have saned user)
# user = daemon
# *BSD
#user = root
user = saned
# Group to be used
#=================
# Linux (most distributions use the lp group to access scanners)
# group = lp
# ArchLinux (ArchLinux uses the scanner group)
# group = scanner
#
# *BSD (no group lp here, use daemon instead)
# group = daemon # root
#
#group = scanner
group = saned
# the saned executable for manager-mode
saned = "/usr/sbin/saned"
saned_opt = {} # string-list
saned_env = { "SANE_CONFIG_DIR=/etc/scanbd" } # list of environment vars for saned
# Scriptdir specifies where scanbd normally looks for scripts.
# The scriptdir option can be defined as:
# - a path relative to the configuations (<path>/etc/scanbd) directory
# - an abosolute path
# Examples:
# scriptdir = scripts
# sets scriptdir to <path>/etc/scanbd/scripts.
# scriptdir = /some/path
# sets scriptdir to the specified absolute path
# Default scriptdir is <path>/etc/scanbd, this is normally appropriate
scriptdir = /etc/scanbd/scripts
# Scripts to execute upon device insertion/removal.
# It can be necessary to load firmware into the device when it is first
# inserted. For example, scanbuttond backend does not know how to load
# scanner firmware, and it can be rectified by making a custom script.
# A simple command like "scanimage -L" in an example insert.script
# invokes saned and it loads the appropriate firmware if necessary.
# These scripts receive environmental variables named in the "environment" subsection:
# SCANBD_DEVICE - device name (fixed string "dbus device" for dbus notification)
# SCANBD_ACTION - "insert" or "remove", so one script can be used.
# device_insert_script = "insert.script"
# device_remove_script =
# scanbuttond_backends_dir sets the path where scanbd looks for the scanbuttond backends
# It can be defined as relative path, starting from the scanbd config directory or
# as an absolute path
# Default is <libdir>/scanbd/scanbutond/backends
# Example
# scanbuttond_backends_dir = "/usr/local/lib/scanbd/scanbuttond/backends"
# poll timeout in [ms]
# (for polling the devices)
timeout = 500
pidfile = "/var/run/scanbd.pid"
# env-vars for the scripts
environment {
# pass the device label as below in this env-var
device = "SCANBD_DEVICE"
# pass the action label as below in this env-var
action = "SCANBD_ACTION"
}
# function definitions
# values of the options are simply passed via env-vars
function function_knob {
filter = "^message.*"
desc = "The value of the function knob / wheel / selector"
env = "SCANBD_FUNCTION"
}
function function_mode {
filter = "^mode.*"
desc = "Color mode"
env = "SCANBD_FUNCTION_MODE"
}
multiple_actions = true # allow multiple actions per option (up to the total amount of options)
# action definitions
# if the filter matches and the value changes
# from from-value to to-value,
# <script> is executed
# <script> is the full pathname (do not include any parameters)
# if parameters are needed, write a script
# since we can have only at most one action for each option, the action-script
# can use the function definition (see above) to distinguish different tasks
# (e.g. use the env-var SCANBD_FUNCTION defined above)
# green button
action scan {
filter = "^start.*"
numerical-trigger {
from-value = 0
to-value = 1
}
desc = "Scan to file"
script = "scan.sh"
}
# red button
action stop {
filter = "^stop.*"
numerical-trigger {
from-value = 0
to-value = 1
}
desc = "Scan to file"
script = "scan.sh"
}
}
# include
# include another file at this point. This may only occur outside general and devices blocks.
# an include statement may be relative to the direcory where scanbd.conf is located or absolute
# include("scanner.d/myscanner.conf")
# include("/my/long/path/myscanner.conf")
# devices
# each device can have actions and functions, you can disable not relevant devices
#include(scanner.d/avision.conf)
#include(scanner.d/fujitsu.conf)
#include(scanner.d/hp.conf)
#include(scanner.d/pixma.conf)
#include(scanner.d/snapscan.conf)
#include(scanner.d/canon.conf)
#include(scanner.d/plustek.conf)
@fehlfarbe
Copy link
Author

Runs /etc/scanbd/scripts/scan.sh when the green or red button on the scanner is pushed. Currently I don't know how to get events from the other buttons or read the selected job Id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment