-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbclabel.sh
executable file
·38 lines (32 loc) · 1 KB
/
bclabel.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
#!/bin/bash
# Takes arguments and puts it as text in a templated label for our labelprinter
if [[ $# -eq 0 ]] ; then
echo 'No arguments given, exiting...'
exit 0
fi
echo $*
if [ "$(echo $1 | awk '{print substr($0,0,3)}')" == "0x" ] ; then
#This is a sanitised input from nurdbot.
#INPUT=$(python3 -c "print(bytes.fromhex('$1'.strip()[2:]).decode('utf8'))")
INPUT=$(python -c "print('$1'[2:].decode('hex'))")
else
INPUT="$*"
fi
echo $INPUT
cd /home/labelprinter/nurdbotlabelprinting/
cp emptybc.png outputbc.png
convert outputbc.png outputbc.gif
convert outputbc.gif -background none -font "Garuda.ttf" -gravity South\
-size 734x367 -pointsize 45 caption:"BCID: $INPUT" -layers flatten outputbc.gif
convert outputbc.gif -rotate 90 outputbc.gif
# print!
lp -d SII_SLP650 outputbc.gif
# print linefeed (newline)
# echo `>|` > echo.lp
#lp -d SII_SLP650 echo.lp
# view output
#qiv outputbc.gif
#log
echo $INPUT >> bclabel.log
#code for moving to next empty label but it's not reliable
printf "\f" |lpr -P SII_SLP650