50 lines
1.2 KiB
Bash
Executable File
50 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
CLASSNAME="svnProfiler"
|
|
TITLE_FILENAME="/tmp/title.png"
|
|
touch "$TITLE_FILENAME"
|
|
|
|
get_window_id() {
|
|
while true; do
|
|
id="$(xdotool search --classname "$CLASSNAME")"
|
|
if test "$?" -ne 0; then
|
|
continue
|
|
fi
|
|
|
|
echo "$id"
|
|
break
|
|
done
|
|
}
|
|
|
|
printf "Database profile: "
|
|
read profile
|
|
if test "$profile" == "development"; then
|
|
databaseName="sevenkeys_development"
|
|
else
|
|
databaseName="sevenkeys"
|
|
fi
|
|
|
|
STORAGE_DIR="$HOME/.local/share/sevenkeys/scanimages/"
|
|
cd "$STORAGE_DIR"
|
|
|
|
files="$(find *.png)"
|
|
|
|
nsxiv -N "$CLASSNAME" $files &
|
|
nsxivWindowId="$(get_window_id)"
|
|
nsxiv "$TITLE_FILENAME" &
|
|
|
|
for file in $files; do
|
|
cardLocationId="$(mysql --silent --silent --user=root --password="$(pass show sevenkeys/mysql)" -e "USE $databaseName; SELECT CardLocationId FROM CardScan WHERE Filename = '$file';")"
|
|
|
|
# TODO: Detect features of the card automatically
|
|
#convert "$file" -crop 1200x120+90+100 "$TITLE_FILENAME"
|
|
#title="$(tesseract --psm 9 "$TITLE_FILENAME" stdout)"
|
|
#echo "$title"
|
|
|
|
cardPrintingId="$(sevenkeys --profile="$profile" search-printings)"
|
|
|
|
sevenkeys --profile="$profile" replace --card-location-id="$cardLocationId" --card-printing-id="$cardPrintingId"
|
|
|
|
xdotool key --window "$nsxivWindowId" 'n'
|
|
done
|