blob: ff59834ff2e7a213e38ccfb7674d6eb0079e7d6a (
plain)
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
# Maintained by CommandIR Support mini at commandir.com - Comments / Suggestions Welcome.
# Modified for LinHES specifics
echo $@ > /tmp/change_channel.log
. /etc/systemconfig
LOCKFILE=/tmp/lirclock
export PATH=/bin:/usr/bin:/usr/local/bin
function post_channel(){
if [ -f $MYTHHOME/post_channel_change ]
then
echo "CALLING $MYTHHOME/post_channel $TRANSMITTER"
$MYTHHOME/post_channel $TRANSMITTER
fi
}
function change_channel() {
touch $LOCKFILE
irsend SET_TRANSMITTERS $TRANSMITTER
sleep .15
case $cmd in
[0-9]*)
for digit in $(echo $cmd | sed -e 's/./& /g')
do
irsend SEND_ONCE $REMOTE_NAME $digit
sleep $DELAY
done
if [ x$SENDKEY != "x" ]
then
irsend SEND_ONCE $REMOTE_NAME $SENDKEY
fi
;;
*)
irsend SEND_ONCE $REMOTE_NAME $cmd
;;
esac
}
function showhelp(){
echo "IR Control Script for LIRC
Includes support for CommandIR transmitter selection and lockfile.
The remote codes will be specific to the transmitter number and matched via /etc/systemconfig
Usage:
$0 -d delay -c channel -n transmitter_number -s Enter
-d delay in tenths of a seconds -
-c channel or cmd
-n transmitter_number
-s Key to send after executing change channel command (optional)
Sends an IR command or sequence of numbers using via emitter TRANSMITTER_NUM.
DELAY ( in 10th of seconds) is waited between sending IR commands.
Example: Change to channel 123 using emitter 2 with a 0.3s pause between digits:
$0 -n1 -c123 -d3
"
exit 1
}
function testvars() {
if [ x$DELAY = "x" ]
then
tdelay="HostTransmitDelay_$TRANSMITTER"
d=${!tdelay}
DELAY=$(echo "scale=2; $d / 10" | bc)
fi
if [ x$cmd = "x" ]
then
echo "-c is mandatory"
exit 1
fi
if [ x$TRANSMITTER = "x" ]
then
echo "-n is mandatory"
exit 1
fi
echo "delay is $DELAY"
# echo "channel or button name is $cmd"
# echo "Using transmitter $TRANSMITTER"
# echo "Remote name is $REMOTE_NAME"
# echo "Will send key $SENDKEY after numbers"
}
#-----------------------------Main Program-----------------------
while getopts ":d:c:n:hs:" opt; do
case $opt in
h) showhelp
;;
d) DELAY=$(echo "scale=2; $OPTARG / 10" | bc)
;;
c) cmd=$OPTARG
;;
n) TRANSMITTER=$OPTARG
tname="HostTransmitproto_$TRANSMITTER"
REMOTE_NAME=${!tname}
if [ x$REMOTE_NAME = "xnone" ]
then
echo "Please define Transmitters in /etc/systemconfig"
exit 1
fi
if [ x$REMOTE_NAME = "x" ]
then
echo "Please define Transmitters in /etc/systemconfig"
exit 1
fi
;;
s) SENDKEY=$OPTARG
;;
\?)
echo
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
testvars
while [ -f $LOCKFILE ]
do
echo "Waiting for change channel lock file..."
sleep .1
done
change_channel
post_channel
rm -f /tmp/lirclock
|