-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscan
executable file
·30 lines (21 loc) · 1.19 KB
/
scan
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
#!/bin/sh
###################################################################
# Script Name : scan
# Description : A simple script to pick scanner and scan picture.
# Args :
# Dependencies : dmenu, scanimage
# Variables :
# Author : Mateusz Reszka
# Email : [email protected]
###################################################################
format='png'
[[ -z "$1" ]] && filename=$(echo "" | dmenu -f -p "Provide filename") || filename=$1
[[ -z "$filename" ]] && echo "File name not provided" && exit 1
device=$(scanimage -f "%d%n" -n | dmenu -l 15 -p "Select printer:")
[[ -z "$device" ]] && echo "Device not selected" && exit 1
resolution=$(scanimage -d $device -A -n | grep 'resolution auto' | sed -r 's/(--resolution auto[|]{2})//g; s/\[(\w){2,3}\]//g; s/ //g; s/dpi//g; s/\|/\n/g' | dmenu -l 15 -p "Provide resolution (default 150dpi)")
mode=$(scanimage -d $device -A -n | grep 'mode auto' | sed -r 's/(--mode)//g; s/\[(\w){4,8}\]//g; s/ //g; s/\|/\n/g' | dmenu -l 15 -p "Provide mode:")
[[ -z "$resolution" ]] && resolution='150'
[[ -z "$mode" ]] && mode="Color"
resdpi=$resolution"dpi"
scanimage -d $device --resolution $resdpi --mode $mode --format $format -o $filename".png" -p 1>&2