From b1ce186fd2a5a81a682994dfd199b75df908b658 Mon Sep 17 00:00:00 2001
From: Trenton Schulz <trenton@norwegianrockcat.com>
Date: Sun, 4 Jun 2023 07:32:21 +0200
Subject: [PATCH] Add a scanbd port.

scanbd looks to be the continuation of scanbuttond, it accomplishes
the same tasks, but supports all scanners from scanbuttond plus all
the scanners supported by SANE. It uses dbus for communication and can
also signal device insertion and removal.

Upstream has moved to gitlab, so this is the last corresponding release
based on the last SourceForge release (with some minor documentation
updates).

To answer the portlint warning, there is no --disable-gettext that
configure knows about.
---
 sysutils/scanbd/Makefile        | 38 +++++++++++++++++++++++++++++++++
 sysutils/scanbd/distinfo        |  3 +++
 sysutils/scanbd/files/scanbd.in | 16 ++++++++++++++
 sysutils/scanbd/pkg-descr       | 17 +++++++++++++++
 sysutils/scanbd/pkg-plist       | 17 +++++++++++++++
 5 files changed, 91 insertions(+)
 create mode 100644 sysutils/scanbd/Makefile
 create mode 100644 sysutils/scanbd/distinfo
 create mode 100755 sysutils/scanbd/files/scanbd.in
 create mode 100644 sysutils/scanbd/pkg-descr
 create mode 100644 sysutils/scanbd/pkg-plist

diff --git a/sysutils/scanbd/Makefile b/sysutils/scanbd/Makefile
new file mode 100644
index 000000000000..155162253310
--- /dev/null
+++ b/sysutils/scanbd/Makefile
@@ -0,0 +1,38 @@
+PORTNAME=	scanbd
+DISTVERSION=	1.5.1
+CATEGORIES=	sysutils
+
+MAINTAINER=	trueos@norwegianrockcat.com
+COMMENT=	Scanbd is a scanner button daemon
+WWW=	https://sourceforge.net/projects/scanbd/
+
+LICENSE=	GPLv2
+
+BUILD_DEPENDS=	sane-config:graphics/sane-backends
+LIB_DEPENDS=	libdbus-1.so:devel/dbus \
+		libudev.so:devel/libudev-devd \
+		libconfuse.so:devel/libconfuse
+RUN_DEPENDS=	bash:shells/bash \
+		scanimage:graphics/sane-backends
+
+USES=	gettext-runtime gmake pkgconfig shebangfix
+
+USE_GITLAB=	yes
+GL_ACCOUNT=	sane-project/frontend
+GL_PROJECT=	scanbd
+GL_COMMIT=	4503640d202c06510f21848a684e221f613f324b
+
+GNU_CONFIGURE=	yes
+
+CONFIGURE_ARGS+=	--with-user --with-group
+
+SHEBANG_GLOB= *.script
+
+USE_RC_SUBR=	scanbd
+
+SUB_FILES=	scanbd
+
+post-install:
+	${INSTALL_SCRIPT} ${WRKDIR}/scanbd ${STAGEDIR}${PREFIX}/etc/rc.d/scanbd
+
+.include <bsd.port.mk>
diff --git a/sysutils/scanbd/distinfo b/sysutils/scanbd/distinfo
new file mode 100644
index 000000000000..43296e31a0d7
--- /dev/null
+++ b/sysutils/scanbd/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1685858862
+SHA256 (sane-project/frontend-scanbd-4503640d202c06510f21848a684e221f613f324b_GL0.tar.gz) = 085d6c0e54048d3ab002f2d9b2a08d31ee3751d04c16cb7ed8826d58d06a54d6
+SIZE (sane-project/frontend-scanbd-4503640d202c06510f21848a684e221f613f324b_GL0.tar.gz) = 473189
diff --git a/sysutils/scanbd/files/scanbd.in b/sysutils/scanbd/files/scanbd.in
new file mode 100755
index 000000000000..e2924b9c6f9b
--- /dev/null
+++ b/sysutils/scanbd/files/scanbd.in
@@ -0,0 +1,16 @@
+#!/bin/sh
+# PROVIDE: scanbd
+# REQUIRE: DAEMON FILESYSTEMS dbus
+# KEYWORD:
+
+. /etc/rc.subr
+
+name=scanbd
+# scanbd_user=saned  # Fix this
+rcvar=scanbd_enable
+command_args=""
+command="%%PREFIX%%/sbin/${name}"
+
+load_rc_config $name
+run_rc_command "$1"
+
diff --git a/sysutils/scanbd/pkg-descr b/sysutils/scanbd/pkg-descr
new file mode 100644
index 000000000000..e868cf3a1a6c
--- /dev/null
+++ b/sysutils/scanbd/pkg-descr
@@ -0,0 +1,17 @@
+scanbd is daemon that listens for scanner button presses and can run scripts.
+
+From the project page:
+
+scanbd is a scanner button daemon. It polls the scanner buttons
+looking for buttons pressed or function knob changes or other scanner
+events as paper inserts / removals and at the same time allows also
+scan-applications to access the scanners. If buttons are pressed,
+etc., various actions can be submitted (scan, copy, email, ...) via
+action scripts. The function knob values are passed to the
+action-scripts as well. Scan actions are also signaled via dbus. This
+can be useful for foreign applications. Scans can also be triggered
+via dbus from foreign applications. On platforms which support
+signaling of dynamic device insertion / removal (libudev, dbus, hal)
+scanbd supports this as well. scanbd can use all sane-backends or some
+special backends from the (old) scanbuttond project. Supported
+platforms: Linux, FreeBSD, NetBSD, OpenBSD
diff --git a/sysutils/scanbd/pkg-plist b/sysutils/scanbd/pkg-plist
new file mode 100644
index 000000000000..11a68ee236ce
--- /dev/null
+++ b/sysutils/scanbd/pkg-plist
@@ -0,0 +1,17 @@
+%%ETCDIR%%/scripts/action.script
+%%ETCDIR%%/scripts/example.script
+%%ETCDIR%%/scripts/insert.script
+%%ETCDIR%%/scripts/scanadf.script
+%%ETCDIR%%/scripts/test.script
+%%ETCDIR%%/scanbd.conf
+%%ETCDIR%%/scanner.d/avision.conf
+%%ETCDIR%%/scanner.d/canon.conf
+%%ETCDIR%%/scanner.d/fujitsu.conf
+%%ETCDIR%%/scanner.d/hp.conf
+%%ETCDIR%%/scanner.d/pixma.conf
+%%ETCDIR%%/scanner.d/plustek.conf
+%%ETCDIR%%/scanner.d/snapscan.conf
+sbin/scanbd
+sbin/scanbm
+man/man8/scanbm.8.gz
+man/man8/scanbd.8.gz
-- 
2.40.1