58
58
#Make sure that all variables are there, and also create the file if
61
for VAR in REMOTE REMOTE_MODULES REMOTE_DRIVER REMOTE_DEVICE REMOTE_LIRCD_CONF REMOTE_LIRCD_ARGS TRANSMITTER TRANSMITTER_MODULES TRANSMITTER_DRIVER TRANSMITTER_DEVICE TRANSMITTER_LIRCD_CONF TRANSMITTER_LIRCD_ARGS START_LIRCD START_LIRCMD LOAD_MODULES LIRCMD_CONF FORCE_NONINTERACTIVE_RECONFIGURATION
61
for VAR in REMOTE REMOTE_MODULES REMOTE_DRIVER REMOTE_DEVICE REMOTE_SOCKET REMOTE_LIRCD_CONF REMOTE_LIRCD_ARGS TRANSMITTER TRANSMITTER_MODULES TRANSMITTER_DRIVER TRANSMITTER_DEVICE TRANSMITTER_SOCKET TRANSMITTER_LIRCD_CONF TRANSMITTER_LIRCD_ARGS START_LIRCD START_LIRCMD LOAD_MODULES LIRCMD_CONF FORCE_NONINTERACTIVE_RECONFIGURATION
63
63
# Patch provided by Robert Bihlmeyer <robbe@orcus.priv.at>
64
64
# See http://bugs.debian.org/303078
127
127
#Present the user with some choices
128
128
#To later explain what this is actually doing without man pages:
129
129
#First, only grab lines with a ;
131
130
#Now, remove all commas from streams
132
131
#Now, Remove all remaining comments or ['s
133
132
#Now, Print the remote name
133
#Next, sort the list and remove duplicates
134
134
#Now, Affix a comma and space to all starts of lines
135
135
#Lastly, change the newline to a null character
136
REMOTES=`grep ";" /usr/share/lirc/lirc.hwdb | sort | sed 's/,//g' | awk -F ";" '$0!~/^#|^\[/{print $1}' | sed 's/^/,\ /' | tr '\n' '\0'`
137
TRANSMITTERS=`grep ";" /usr/share/lirc/transmitter.hwdb | sort | sed 's/,//g' | awk -F ";" '$0!~/^#|^\[/{print $1}' | sed 's/^/,\ /' | tr '\n' '\0'`
136
REMOTES=`cat /usr/share/lirc/lirc.hwdb /usr/share/lirc/extras/more_remotes.hwdb 2>/dev/null | grep ";" | sed 's/,//g' | awk -F ";" '$0!~/^#|^\[/{print $1}' | sort -u | sed 's/^/,\ /' | tr '\n' '\0'`
138
137
db_subst lirc/remote REMOTES $REMOTES
139
db_subst lirc/transmitter TRANSMITTERS $TRANSMITTERS
139
if [ -f /usr/share/lirc/extras/transmitter.hwdb ]; then
140
TRANSMITTERS=`grep ";" /usr/share/lirc/extras/transmitter.hwdb | sort | sed 's/,//g' | awk -F ";" '$0!~/^#|^\[/{print $1}' | sed 's/^/,\ /' | tr '\n' '\0'`
141
db_subst lirc/transmitter TRANSMITTERS $TRANSMITTERS
141
144
#If we are forcing a reconfigure, then our old remote and new ones are the same
142
145
if [ "$FORCE_NONINTERACTIVE_RECONFIGURATION" = "true" ]; then
145
148
db_set lirc/remote $CHOSEN_REMOTE
147
150
db_input high lirc/remote || true
148
db_input high lirc/transmitter || true
151
if [ -f /usr/share/lirc/extras/transmitter.hwdb ]; then
152
db_input high lirc/transmitter || true
151
156
#Populate remote information (remote is our primary device at all times)
156
161
if [ "$CHOSEN_REMOTE" != "None" -a "$CHOSEN_REMOTE" != "Custom" ] && [ "$OLDREMOTE" != "$CHOSEN_REMOTE" -o "$FORCE_NONINTERACTIVE_RECONFIGURATION" = "true" ]; then
157
REMOTE_MODULES=`grep ";" /usr/share/lirc/lirc.hwdb | sort | sed 's/,//g' | grep "${CHOSEN_REMOTE}" | awk -F ";" '$0!~/^#|^\[/{print $3}'`
158
REMOTE_DRIVER=`grep ";" /usr/share/lirc/lirc.hwdb | sort | sed 's/,//g' | grep "${CHOSEN_REMOTE}" | awk -F ";" '$0!~/^#|^\[/{print $2}'`
159
REMOTE_LIRCD_CONF=`grep ";" /usr/share/lirc/lirc.hwdb | sort | sed 's/,//g' | grep "${CHOSEN_REMOTE}" | awk -F ";" '$0!~/^#|^\[/{print $5}'`
162
#To later explain what this is actually doing without man pages:
163
#First, only grab lines with a ;
164
#Now, remove all commas from streams
165
#Lastly, take the last matching entry found (so remotes.hwdb overrides lirc.hwdb)
166
REMOTE_LINE=`cat /usr/share/lirc/lirc.hwdb /usr/share/lirc/extras/more_remotes.hwdb 2>/dev/null | grep ";" | sed 's/,//g' | grep "${CHOSEN_REMOTE}" | tail -1`
167
#Remove all remaining comments or ['s
168
#then print the remote name
169
REMOTE_MODULES=`echo $REMOTE_LINE | awk -F ";" '$0!~/^#|^\[/{print $3}'`
170
REMOTE_DRIVER=`echo $REMOTE_LINE | awk -F ";" '$0!~/^#|^\[/{print $2}'`
171
REMOTE_LIRCD_CONF=`echo $REMOTE_LINE | awk -F ";" '$0!~/^#|^\[/{print $5}'`
160
172
SUPPORTED_DRIVERS=`lircd -H help 2>&1 | awk '$0!~/^S|^D/{print $1}' | tr '\n' '\ '`
162
174
#/dev/input/eventX is a weird case: filter it
254
266
CHOSEN_TRANSMITTER="${RET}"
257
if [ "$CHOSEN_TRANSMITTER" != "None" -a "$CHOSEN_TRANSMITTER" != "Custom" ] && [ "$OLDTRANSMITTER" != "$CHOSEN_TRANSMITTER" -o "$FORCE_NONINTERACTIVE_RECONFIGURATION" = "true" ]; then
258
TRANSMITTER_MODULES=`grep ";" /usr/share/lirc/transmitter.hwdb | sort | sed 's/,//g' | grep "${CHOSEN_TRANSMITTER}" | awk -F ";" '$0!~/^#|^\[/{print $3}'`
259
TRANSMITTER_DRIVER=`grep ";" /usr/share/lirc/transmitter.hwdb | sort | sed 's/,//g' | grep "${CHOSEN_TRANSMITTER}" | awk -F ";" '$0!~/^#|^\[/{print $2}'`
260
TRANSMITTER_LIRCD_CONF=`grep ";" /usr/share/lirc/transmitter.hwdb | sort | sed 's/,//g' | grep "${CHOSEN_TRANSMITTER}" | awk -F ";" '$0!~/^#|^\[/{print $5}'`
269
if [ -f /usr/share/lirc/extras/transmitter.hwdb ] && [ "$CHOSEN_TRANSMITTER" != "None" -a "$CHOSEN_TRANSMITTER" != "Custom" ] && [ "$OLDTRANSMITTER" != "$CHOSEN_TRANSMITTER" -o "$FORCE_NONINTERACTIVE_RECONFIGURATION" = "true" ]; then
270
TRANSMITTER_LINE=`grep ";" /usr/share/lirc/extras/transmitter.hwdb | sed 's/,//g' | grep "${CHOSEN_TRANSMITTER}" | tail -1`
271
TRANSMITTER_MODULES=`echo $TRANSMITTER_LINE | awk -F ";" '$0!~/^#|^\[/{print $3}'`
272
TRANSMITTER_DRIVER=`echo $TRANSMITTER_LINE | awk -F ";" '$0!~/^#|^\[/{print $2}'`
273
TRANSMITTER_LIRCD_CONF=`echo $TRANSMITTER_LINE | awk -F ";" '$0!~/^#|^\[/{print $5}'`
261
274
#transmitter.hwdb puts none rather than ;;
262
275
if [ "$TRANSMITTER_MODULES" != "none" ]; then
263
276
#if we have a module in use, don't use a driver too
449
462
#if we have a remote, include it's config
450
if [ -f "/usr/share/lirc/remotes/$REMOTE_LIRCD_CONF" ];then
463
if [ -f "/usr/share/lirc/extras/more_remotes/$REMOTE_LIRCD_CONF" ];then
464
cat >> /etc/lirc/lircd.conf <<EOF
465
#Configuration for the $REMOTE remote:
466
include "/usr/share/lirc/extras/more_remotes/$REMOTE_LIRCD_CONF"
469
elif [ -f "/usr/share/lirc/remotes/$REMOTE_LIRCD_CONF" ];then
451
470
cat >> /etc/lirc/lircd.conf <<EOF
452
471
#Configuration for the $REMOTE remote:
453
472
include "/usr/share/lirc/remotes/$REMOTE_LIRCD_CONF"
471
490
#if we have a transmitter, include it's config
472
if [ -f "/usr/share/lirc/transmitters/$TRANSMITTER_LIRCD_CONF" ];then
491
if [ -f "/usr/share/lirc/extras/transmitters/$TRANSMITTER_LIRCD_CONF" ];then
473
492
cat >> /etc/lirc/lircd.conf <<EOF
474
493
#Configuration for the $TRANSMITTER transmitter:
475
include "/usr/share/lirc/transmitters/$TRANSMITTER_LIRCD_CONF"
494
include "/usr/share/lirc/extras/transmitters/$TRANSMITTER_LIRCD_CONF"
477
496
elif [ -f "$TRANSMITTER_LIRCD_CONF" ]; then
478
497
cat >> /etc/lirc/lircd.conf <<EOF
514
533
if [ "$1" = "configure" ]; then
535
#0.8.6 got rid of mceusb2 so users need to repick remotes
536
if dpkg --compare-versions "$2" le-nl "0.8.6-0ubuntu1"; then
537
db_fset lirc/remote seen false
538
db_fset lirc/transmitter seen false
516
541
if [ -e "/etc/modprobe.d/lirc-serial" ]; then
517
542
echo "Preserving user changes to /etc/modprobe.d/lirc-serial.conf ..."
518
543
if [ -e "/etc/modprobe.d/lirc-serial.conf" ]; then
579
604
# we don't restore the file unless the user is (re)configuring
580
605
elif $CONFIG_CHANGED \
606
&& [ -f "/usr/share/lirc/extras/more_remotes/$RET" ];then
607
echo trying default lircmd.conf
608
cp /usr/share/lirc/extras/more_remotes/$RET \
609
/etc/lirc/lircmd.conf
610
elif $CONFIG_CHANGED \
581
611
&& [ -f "/usr/share/lirc/remotes/$RET" ];then
582
612
echo trying default lircmd.conf
583
613
cp /usr/share/lirc/remotes/$RET \