/
pronto2hex
executable file
·68 lines (58 loc) · 1.56 KB
/
pronto2hex
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
#!/bin/sh
usage () {
echo "USAGE: `basename $0` [options] <pronto file>"
echo "The following options are recognized:"
echo " -r|--keep-raw Skips the step of converting raw lirc codes"
echo " into more readable codes. Although this step"
echo " often creates more reliable configuration it"
echo " sometimes fails with"
echo " 'irrecord: decoding of <code> failed' errors."
echo " In this case, use this switch to skip this"
echo " conversion and use the raw codes."
exit 1
}
pronto_file=
keep_raw=
for arg in "$@"; do
case $arg in
-r|--keep-raw)
keep_raw=1
shift # past argument
;;
-h|--help)
usage
;;
-*)
echo -e "Invalid argument: $arg"
usage
;;
*)
pronto_file=$arg
;;
esac
done
pronto_file=$1
if [ ! -f "$pronto_file" ] ; then
echo "Cannot find input file '$pronto_file'"
usage
fi
if [ -f lircd.conf ] ; then
echo "Move or delete lircd.conf."
exit 1
fi
echo "Creating lircd.conf..."
python `dirname $0`/pronto2lirc.py $pronto_file
if [ ! -f lircd.conf ] ; then
echo "Failed to create lircd.conf. Quiting."
exit 1
fi
hex_file=`basename $pronto_file .pronto`.lircd.conf
echo "Creating $hex_file..."
if [ "$keep_raw" ] ; then
cp lircd.conf $hex_file
else
irrecord -a lircd.conf > $hex_file
fi
echo "Removing lircd.conf..."
rm lircd.conf
echo "Done"