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
|
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: i8kbuttons
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Dell Inspiron volume buttons monitor
# Description: Enable service provided by daemon
### END INIT INFO
#
# i8kbuttons Dell Inspiron volume buttons monitor
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Modified for i8kutils by Massimo Dal Zotto <dz@debian.org> and
# Bradley Smith <bradsmith@debian.org>
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
DAEMON=/usr/bin/i8kbuttons
PROC_I8K=/proc/i8k
NAME=i8kbuttons
DESC="Dell Inspiron volume buttons monitor"
PIDFILE=/var/run/$NAME.pid
ENABLED=0
test -x $DAEMON || exit 0
if [ -f /etc/default/$NAME ]; then
. /etc/default/$NAME
fi
i8k_setkeycodes() {
kvers="$(uname -r)"
test "${kvers#2.6.}" != "$kvers" || return
test "$I8KBUTTONS_SETKEYCODES" = true || return
keys=$(getkeycodes | grep "^e0 00" | awk '{print $4,$5}')
test "$keys" = "${I8K_KEY_PLAY:-171} ${I8K_KEY_STOP:-172}" && return
setkeycodes ${I8K_SCAN_PLAY:-e001} ${I8K_KEY_PLAY:-171}
setkeycodes ${I8K_SCAN_STOP:-e002} ${I8K_KEY_STOP:-172}
setkeycodes ${I8K_SCAN_PREV:-e003} ${I8K_KEY_PREV:-187}
setkeycodes ${I8K_SCAN_NEXT:-e004} ${I8K_KEY_NEXT:-189}
setkeycodes ${I8K_SCAN_MUTE:-e020} ${I8K_KEY_MUTE:-113}
setkeycodes ${I8K_SCAN_VOLD:-e02e} ${I8K_KEY_VOLD:-114}
setkeycodes ${I8K_SCAN_VOLU:-e030} ${I8K_KEY_VOLU:-114}
}
case "$1" in
start)
if [ "$ENABLED" = 0 ]; then
log_warning_msg "Not starting. Disabled via /etc/default/$NAME."
exit 0
fi
i8k_setkeycodes >/dev/null 2>&1 || true
test -n "$I8KBUTTONS_UP_CMD" -o \
-n "$I8KBUTTONS_DOWN_CMD" -o \
-n "$I8KBUTTONS_MUTE_CMD" \
|| exit 0
log_daemon_msg "Starting $DESC" "$NAME"
modprobe i8k >/dev/null 2>&1 || true
if [ ! -f "$PROC_I8K" ]; then
log_progress_msg "Could not find $PROC_I8K."
log_end_msg 1
exit 1
fi
start-stop-daemon --start --quiet --make-pidfile \
--pidfile $PIDFILE \
--background --exec $DAEMON -- \
--up "$I8KBUTTONS_UP_CMD" \
--down "$I8KBUTTONS_DOWN_CMD" \
--mute "$I8KBUTTONS_MUTE_CMD" \
--timeout "${I8KBUTTONS_TIMEOUT:-100}" \
--repeat "${I8KBUTTONS_REPEAT:-0}"
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE
log_end_msg $?
rm -f $PIDFILE
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME
;;
restart|reload|force-reload)
$0 stop && sleep 2 && $0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
|