macbook-tools/macbook-tools-init

85 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

2013-01-24 01:00:00 +01:00
#!/bin/bash
#
# Macbook tools initscript
# Copyright (c) 2006-2009 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Released under the GPL v.2 license
#
# /etc/rc.d/init.d/macbook-tools
#
# chkconfig: 345 42 58
# description: set screen backlight level and load iSight firmware on Apple MacBooks
# processname: macbook-tools
# Source function library.
. /etc/rc.d/init.d/functions
[ -e /etc/sysconfig/machine ] && . /etc/sysconfig/machine
# Check for Apple manufacturer or exit
[ "${SYSTEM_MANUFACTURER:0:5}" = "Apple" ] || {
sed -i "s|KEYMAP=it-macbook|KEYMAP=it|" /etc/vconsole.conf
exit 0
}
[ -f /etc/sysconfig/macbook-tools ] && . /etc/sysconfig/macbook-tools
sed -i "s|KEYMAP=it$|KEYMAP=it-macbook|" /etc/vconsole.conf
[ "$BACKLIGHT_LEVEL" ] || BACKLIGHT_LEVEL=190
RETVAL=0
#
# See how we were called.
#
start() {
[ -e /sys/devices/platform/applesmc.768 ] || modprobe applesmc
if [ "$IR_EVENT_DEVICE" ]; then
echo -n "Starting lircd for Apple IR remote: "
lircd -H macmini /etc/lirc/apple/lircd.conf.macmini
evaluate_retval
echo
fi
#echo -n "Setting middle and right click mouse emulation: "
#echo 1 > /proc/sys/dev/mac_hid/mouse_button_emulation
#echo 125 > /proc/sys/dev/mac_hid/mouse_button2_keycode
#echo 96 > /proc/sys/dev/mac_hid/mouse_button3_keycode
#evaluate_retval
#echo
echo -n "Loading MacBook light sensor control daemon: "
macbook-lightd &>/dev/null &
evaluate_retval
echo
}
stop() {
echo -n "Stopping MacBook light sensor control daemon: "
killall -9 macbook-lightd
evaluate_retval
echo
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
restart)
restart
;;
*)
INITNAME=`basename $0`
echo "Usage: $INITNAME {start|restart}"
exit 1
esac
exit $RETVAL