Last active
December 21, 2015 08:59
-
-
Save 0mark/6282298 to your computer and use it in GitHub Desktop.
Scanner/Printer Copything
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE=/tmp/kopierkc | |
echo "Searching..." | |
PRINTER=$(LANG=C lpstat -p -d | grep "is idle" | wc -l) | |
if [ $PRINTER -lt 1 ]; then | |
echo "No idle Printer found." | |
exit 1 | |
fi | |
if [ ! -f $FILE -o "$1" == "s" ]; then | |
scanimage -L > ${FILE} | |
fi | |
SCANNER=$(cat $FILE | wc -l) | |
if [ $SCANNER -lt 1 ]; then | |
echo "No Scanner found." | |
exit 1 | |
fi | |
echo "Select..." | |
SCANNER=$(cat $FILE | dmenu -l 10 $DMENUSETTINGS -p 'Select Scanner' | head -n 1 | sed 's/.*`\([^'"'"']\+\).*/\1/g') | |
if [ "$SCANNER" == "" ]; then exit; fi | |
PRINTER=$(LANG=C lpstat -p -d | grep "is idle" | sed 's/printer \(.\+\) is idle.*/\1/g' | dmenu -l 10 $DMENUSETTINGS -p 'Select printer') | |
if [ "$PRINTER" == "" ]; then exit; fi | |
RES=$(echo -e "300\n200\n600\n400\n150\n100\n75" | dmenu -l 10 $DMENUSETTINGS -p 'Select Resolution (DPI)') | |
if [ "$RES" == "" ]; then exit; fi | |
FILE="${FILE}$$" | |
echo "Scanning..." | |
/usr/bin/scanimage -d $SCANNER --mode Gray --resolution $RES -x 210 -y 295 > ${FILE}.pbm | |
# --mode lineart | |
echo "Converting..." | |
/usr/bin/pnmtops -equalpixels -dpi $RES -width 8 -height 11.6 ${FILE}.pbm > ${FILE}.ps | |
rm ${FILE}.pbm | |
echo "Printing..." | |
/usr/bin/lpr -P$PRINTER -o page-set=all ${FILE}.ps | |
rm ${FILE}.ps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILE=/tmp/kopierkc | |
echo "Searching..." | |
if [ ! -f $FILE -o "$1" == "s" ]; then | |
scanimage -L > ${FILE} | |
fi | |
SCANNER=$(cat $FILE | wc -l) | |
if [ $SCANNER -lt 1 ]; then | |
echo "No Scanner found." | |
exit 1 | |
fi | |
echo "Select..." | |
SCANNER=$(cat $FILE | dmenu -l 10 $DMENUSETTINGS -p 'Select Scanner' | head -n 1 | sed 's/.*`\([^'"'"']\+\).*/\1/g') | |
if [ "$SCANNER" == "" ]; then exit; fi | |
#PRINTER=$(LANG=C lpstat -p -d | grep "is idle" | sed 's/printer \(.\+\) is idle.*/\1/g' | dmenu -l 10 $DMENUSETTINGS -p 'Select printer') | |
#if [ "$PRINTER" == "" ]; then exit; fi | |
RES=$(echo -e "300\n200\n600\n400\n150\n100\n75" | dmenu -l 10 $DMENUSETTINGS -p 'Select Resolution (DPI)') | |
if [ "$RES" == "" ]; then exit; fi | |
FILE="${FILE}$$" | |
echo "Scanning..." | |
/usr/bin/scanimage -d $SCANNER --mode Gray --resolution $RES -x 210 -y 295 > ${FILE}.pbm | |
# --mode lineart | |
echo "Converting..." | |
/usr/bin/pnmtojpeg -density ${RES}x${RES}dpi ${FILE}.pbm > ${FILE}.jpg | |
rm ${FILE}.pbm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment