Warning: 2015-10-19: Major upgrade in progress. Site somewhat functional, with bugs...
You are here: Colas>Hacks Web>ScanButtond (14 Jan 2014, ColasNahaboo)Edit Attach
scanbuttond logo

Patch for scanbuttond

I use http://scanbuttond.sourceforge.net/ scanbuttond v0.2.3, a nice linux daemon to trigger actions (shell scripts) on presses on scanner buttons, but after a motherboard upgrade, if failed with a "Segmentation Violation". But debugging it was simply a missing check: while looking for all the configs of the USB devices, the code didn't anticipate for a non-existent (null) config array .You can see the http://hg.colas.nahaboo.net/scanbuttond/rev/e28c5806fe83 one-line fix on my mercurial repository, or just get the patch scanbuttond-nullconfig.patch and apply it with:
patch -p1 <scanbuttond-nullconfig.patch

Patch mailed to the author, and signalled on its https://bugs.launchpad.net/ubuntu/+source/scanbuttond/+bug/151808 Ubuntu bug entry

-- ColasNahaboo - 2008-10-17

Rebuilding a modified debian package

For Debian or Ubuntu:

# set up package for rebuild
mkdir /tmp/scanbuttond; cd /tmp/scanbuttond
for i in scanbuttond_0.2.3-7.dsc scanbuttond_0.2.3.orig.tar.gz scanbuttond_0.2.3-7.diff.gz
do wget http://ftp.de.debian.org/debian/pool/main/s/scanbuttond/$i
dpkg-source -x *.dsc
cd *[^a-z]

# apply patch
wget http://colas.nahaboo.net/pub/Hacks/ScanButtond/scanbuttond-nullconfig.patch
patch -p1 <scanbuttond-nullconfig.patch

# rebuild
dpkg-buildpackage -us -uc
cd ..

# install
sudo dpkg -i *.deb

You can get the packages (~ 30k) I thus compiled on my i386 systems for:

My use of scanbuttond

Since scanbuttond prints 2 lines in /var/log/syslog every 2 seconds if your scanner is not on, like:
Oct 17 22:33:49 mougins scanbuttond: rescanning devices...
Oct 17 22:33:49 mougins scanbuttond: no supported devices found. rescanning in a few seconds...
Oct 17 22:33:51 mougins scanbuttond: rescanning devices...
Oct 17 22:33:51 mougins scanbuttond: no supported devices found. rescanning in a few seconds...

To avoid this I only launch the daemon when my scanner is up and stop it when I turn it off. For this I do not launch /etc/init.d/scanbuttond on startup, but the shell daemon:
# only start scanbuttond if scanner is on, to avoid messages

# a string we must find in the output of "lsusb" if scanner is on
SCANNER_NAME='Seiko Epson Corp. Perfection'

while sleep 20; do
if fgrep -qs "$SCANNER_NAME" /sys/bus/usb/devices/*/product; then
if ! $scan_on; then
/etc/init.d/scanbuttond start
if $scan_on; then
/etc/init.d/scanbuttond stop
done </dev/null >/dev/null 2>&1 &

Note: the above exemple has been sped up on 2014-01-14 by not using lsusb anymore at the suggestion of Tomas Lihan.

And, to be complete, if you want some example, here is my /etc/scanbuttond/buttonpressed.sh script. What it does is
  • on left button, scan & save in a fixed dir /0/scans/new in medium quality: 150dpi, 75% quality jpeg
  • on middle, do a photocopy
  • on right, scan & save in a fixed dir /0/scans/new in high quality: 400 dpi, 90% quality jpeg

Topic revision: r21 - 14 Jan 2014, ColasNahaboo
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Colas? Send feedback