-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindCodes.sh
executable file
·45 lines (35 loc) · 1.06 KB
/
findCodes.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
39
40
41
42
43
44
45
#!/bin/bash
#
# Script to configure a device remote code on lircd installation.
#
# Requirements: git lircd
# Author: Jorge Davison
CODES_DIR=lirc-remotes-code/remotes/
LIRCD_CONF_PATH=/etc/lirc/lircd.conf
_term() {
cat $LIRCD_CONF_PATH >> $LIRCD_CONF_PATH.bck
rm $LIRCD_CONF_PATH
cp $LIRCD_CONF_PATH.bck $LIRCD_CONF_PATH
popd
}
# trap keyboard interrupt (control-c)
trap _term SIGINT
# Backup lircd conf
cp $LIRCD_CONF_PATH $LIRCD_CONF_PATH.bck
pushd $INSTALLATION_PATH
cd $CODES_DIR
printf "Please select the device brand:\n"
select brand in */; do test -n "$brand" && break; echo ">>> Invalid Selection"; done
cd "$brand"
echo "Iteration will begin, please break the script 'Ctrl+C' when your device shutdown"
sleep 2
for filename in *.conf; do
CODE_NAME=$(sed -ne "s/\s*name\s*\(\d*\)\s*/\1/p" $filename)
echo "Testing with file '$filename' (code '$CODE_NAME')..."
rm /etc/lirc/lircd.conf
ln -s $CODES_DIR/$brand/$filename $LIRCD_CONF_PATH
/etc/init.d/lirc restart
echo "Sending KEY_POWER with $CODE_NAME..."
irsend SEND_ONCE $CODE_NAME KEY_POWER
sleep 10
done