This commit is contained in:
2025-12-05 14:00:28 +01:00
parent 542c482013
commit 8aadbdd998
2 changed files with 17 additions and 4 deletions

View File

@@ -138,8 +138,7 @@ accounts = [ACCOUNTNAME]
# #
# Tilde and environment variable expansions will be performed. # Tilde and environment variable expansions will be performed.
# #
#pythonfile = ~/.offlineimap.py pythonfile = $XDG_CONFIG_HOME/msmtp/pass_wrapper.py
# This option is in the [general] section. # This option is in the [general] section.
# #

18
scan
View File

@@ -1,4 +1,4 @@
#!/bin/bash
TEMPDIR=/tmp/scanner/ TEMPDIR=/tmp/scanner/
@@ -6,6 +6,17 @@ RET_SCAN=0
RET_MAGICK=-1 RET_MAGICK=-1
FILENAME="UNDEFINED" FILENAME="UNDEFINED"
#DEVICE=utsushi:esci:usb:0x04B8:0x110B
DEVICE="utsushi:esci:usb:/sys/devices/pci0000:00/0000:00:08.3/0000:13:00.0/usb7/7-1/7-1.2/7-1.2:1.0"
function sendPaperless() {
TOKEN=$(pass show paperless/api-token 2>/dev/null)
curl -X POST \
--url https://5ccppi.org:8080/api/documents/post_document/ \
--header "Authorization: token $TOKEN" \
-F "document=@$1"
echo "curl: " $?
}
if [ ! -d "$TEMPDIR" ]; then if [ ! -d "$TEMPDIR" ]; then
echo "create tempdir as it does not exist" echo "create tempdir as it does not exist"
mkdir $TEMPDIR mkdir $TEMPDIR
@@ -13,7 +24,7 @@ if [ ! -d "$TEMPDIR" ]; then
fi fi
if [ -d "$TEMPDIR" ]; then if [ -d "$TEMPDIR" ]; then
scanimage --tl-x 7 -d utsushi:esci:usb:0x04B8:0x110B --batch="$TEMPDIR/out%d.pnm" \ scanimage --tl-x 7 -d $DEVICE --batch="$TEMPDIR/out%d.pnm" \
--source=ADF \ --source=ADF \
--resolution=200 --resolution=200
RET_SCAN=$? RET_SCAN=$?
@@ -38,7 +49,10 @@ if [ $RET_SCAN == 2 ]; then
fi fi
if [ $RET_MAGICK == 0 ]; then if [ $RET_MAGICK == 0 ]; then
echo "magick sucessful converted $FILENAME" echo "magick sucessful converted $FILENAME"
sendPaperless $FILENAME
xdg-open $FILENAME xdg-open $FILENAME
else else
echo -e "ERROR: magick returned: " $RET_MAGICK " there sems to be nothing to do\n is the paper inserted?" echo -e "ERROR: magick returned: " $RET_MAGICK " there sems to be nothing to do\n is the paper inserted?"
fi fi