-
Notifications
You must be signed in to change notification settings - Fork 1
/
printing-scanning.sh
executable file
·176 lines (134 loc) · 3.83 KB
/
printing-scanning.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
#Content of ~/scripts/gray_scan.sh
grayscan() {
if [[ $1 -eq 0 ]]
then
OUT_DIR=/home/cory/bash-scripts
fi
fileNAME=scan_`date +%Y-%m-%d-%H%M%S`_
echo 'scanning...'
scanimage --verbose\
--page-width 221.121\
--page-height 876.695\
-l 0\
-t 0\
-x 221.121\
-y 876.695\
--ald=yes \
--overscan On \
--prepick=On \
--mode Gray \
--resolution 300 \
--format=png \
--source 'ADF Duplex' \
--swcrop=yes \
--buffermode On \
--swdespeck 2 \
--swdeskew=yes \
--swskip 20% \
--device 'fujitsu:ScanSnap iX500:15419' \
--batch="$OUT_DIR/$fileNAME%03d.png"
printf "Scanned document(s) to:\n\
$(ls --size --block-size=M $OUT_DIR/$fileNAME*)"
echo -e "\n\nDesired filename for scanned document?(please use .png extension) "
read file
echo -e "\n\nScanned file is now called $file"
echo -e "Converting $file to $(basename ${file} .png).pdf..."
i=$(ls -r1) && declare -a PDF && PDF=($i); convert -density 300 ${PDF[@]} $(basename ${file} .png).pdf &> /dev/null
ls *.pdf
echo -e "Removing original .png scans..."
rm *.png
xdg-open $(basename ${file} .png).pdf
}
colorscan() {
if [[ $1 -eq 0 ]]
then
OUT_DIR=/home/cory/bash-scripts
fi
fileNAME=scan_`date +%Y-%m-%d-%H%M%S`_
echo 'scanning...'
scanimage --verbose\
--page-width 221.121\
--page-height 876.695\
-l 0\
-t 0\
-x 221.121\
-y 876.695\
--ald=yes \
--overscan On \
--prepick=On \
--mode Color \
--resolution 300 \
--format=png \
--source 'ADF Duplex' \
--swcrop=yes \
--buffermode On \
--swdespeck 2 \
--swdeskew=yes \
--swskip 20% \
--device 'fujitsu:ScanSnap iX500:15419' \
--batch="$OUT_DIR/$fileNAME%03d.png"
printf "Scanned document(s) to:\n\
$(ls --size --block-size=M $OUT_DIR/$fileNAME*)"
echo -e "\n\nDesired filename for scanned document?(please use .png extension) "
read file
echo -e "\n\nScanned file is now called $file"
echo -e "Converting $file to $(basename ${file} .png).pdf..."
i=$(ls -r1) && declare -a PDF && PDF=($i); convert -density 300 ${PDF[@]} $(basename ${file} .png).pdf &> /dev/null
ls *.pdf
echo -e "Removing original .png scans..."
rm *.png
xdg-open $(basename ${file} .png).pdf
}
mainmenu() {
PS3=$'\n\n'"What would you like to do? "
COLUMNS=1
main=("Scan something" "Print something" "Quit")
printing=("Print a file to the default printer" "List available printers" "Set the default printer" "More options")
while true
do
echo -e "\nMAIN MENU\n\n"
select a in "${main[@]}";
do
case $a in
"Scan something")
echo -e "\nSCAN MENU\n\n"
select ans in "Black and White" "Color" "Return to main menu" "Quit";
do
case $ans in
"Black and White")
grayscan
;;
"Color")
colorscan
;;
"Return to main menu")
mainmenu
;;
"Quit")
exit 0
;;
*) echo -e "Invalid entry. Please try an option on display."
exit 1
;;
esac
done
;;
"Print something")
echo -e "\nPRINT MENU\n\n"
select b in "${printing[@]};
do
case $b in
"Print a file to the default printer")
;;
"Quit")
exit 0
;;
*) echo -e "Invalid entry. Please try an option on display."
exit 1
;;
esac
done
done
}
mainmenu