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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: hotkey-setup
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Set up laptop keys to generate keycodes.
### END INIT INFO
# do not run if not package is not installed
test -x /usr/sbin/dumpkeycodes || exit 0
manufacturer=`dmidecode --string system-manufacturer`
name=`dmidecode --string system-product-name`
version=`dmidecode --string system-version`
SAVED_STATE=/var/run/hotkey-setup
THINKPAD_LOCKFILE=$SAVED_STATE.thinkpad-keys
THINKPAD_PROC_HOTKEY=/proc/acpi/ibm/hotkey
THINKPAD_KEYS=/usr/sbin/thinkpad-keys
xorg_driver() {
if [ -e /etc/X11/xorg.conf ] ; then
driver=$(sed -n -e '/^[ \t]*section[ \\t]*"device"/I,/^[ \t]*endsection/I{/^[ \t]*driver[ \t]*/I{s/^[ \t]*driver[ \t]*"*//I;s/"*[ \t]*$//;p}}' /etc/X11/xorg.conf)
fi
if [ -z "$driver" ] ; then
# Try discover v2, until a better way to detect it is found
xversion=7
driver=$(discover --data-path=xfree86/server/device/driver \
--data-version=$xversion display | head -1)
fi
echo $driver
}
do_video () {
VIDEO=`xorg_driver`
case $VIDEO in
intel|ati|radeon)
for x in /proc/acpi/video/*/DOS; do
if [ -e "$x" ]; then
echo -n 7 >$x;
fi
done
;;
esac
}
# This is here because it needs to be executed both if we have a
# Lenovo that also IDs as a ThinkPad, or if we have a real IBM one.
do_thinkpad () {
. /usr/share/hotkey-setup/ibm.hk
modprobe thinkpad-acpi
VIDEO=`xorg_driver`
case $VIDEO in
intel|ati|radeon)
echo 0xffffff > $THINKPAD_PROC_HOTKEY
;;
esac
# Try to enable the top 8-bits of the mask
sed -e '/mask:/s/.*\(....\)$/0xff\1/p;d' $THINKPAD_PROC_HOTKEY > $THINKPAD_PROC_HOTKEY
# If the top bit (ThinkPad key) sticks, skip the polling-daemon
if ! grep -q '0x[8-9a-f].....$' $THINKPAD_PROC_HOTKEY && test -x $THINKPAD_KEYS; then
if [ ! -c /dev/input/uinput ]; then
modprobe uinput
fi
if [ ! -c /dev/nvram ]; then
modprobe nvram
fi
$THINKPAD_KEYS $1 && touch $THINKPAD_LOCKFILE
fi
}
case "$1" in
start)
# This entire block does nothing on desktops right now
if laptop-detect; then
do_video
/usr/sbin/dumpkeycodes >$SAVED_STATE
if [ $? -gt 0 ]; then
rm -f $SAVED_STATE
fi
. /usr/share/hotkey-setup/key-constants
case "$manufacturer" in
Acer*)
. /usr/share/hotkey-setup/acer.hk
case "$name" in
Aspire\ 16*)
. /usr/share/hotkey-setup/acer-aspire-1600.hk
;;
esac
;;
ASUS*)
. /usr/share/hotkey-setup/asus.hk
;;
Compaq*)
case "$name" in
Armada*E500*|Evo*N620*)
. /usr/share/hotkey-setup/compaq.hk
;;
esac
;;
Dell*)
. /usr/share/hotkey-setup/dell.hk
;;
Hewlett-Packard*)
# Load this _first_, so that it can be overridden
. /usr/share/hotkey-setup/hp.hk
case "$name" in
# Please open a bug if uncommenting these "Presario" entries works for you...
#*Presario\ V2000*)
#. /usr/share/hotkey-setup/hp-v2000.hk
#;;
*Tablet*|*tc*)
. /usr/share/hotkey-setup/hp-tablet.hk
;;
esac
;;
IBM*)
do_thinkpad IBM
;;
LENOVO*)
case "$version" in
*Think[Pp]ad*)
do_thinkpad --no-brightness
;;
*)
. /usr/share/hotkey-setup/lenovo.hk
;;
esac
;;
MEDION*)
case "$name" in
*FID2060*)
. /usr/share/hotkey-setup/medion-md6200.hk
;;
esac
;;
MICRO-STAR*)
case "$name" in
*INFINITY*)
. /usr/share/hotkey-setup/micro-star-infinity.hk
;;
esac
;;
Samsung*|SAMSUNG*)
. /usr/share/hotkey-setup/samsung.hk
;;
Sony*)
modprobe sonypi; # Needed to get hotkey events
modprobe sony-laptop
;;
*)
. /usr/share/hotkey-setup/default.hk
esac
. /usr/share/hotkey-setup/generic.hk
fi
;;
stop)
if [ -f $THINKPAD_LOCKFILE ]; then
pid=`pidof thinkpad-keys`
if [ "$pid" ] ; then
kill $pid || true
fi
rm -f $THINKPAD_LOCKFILE
fi
if [ -f $SAVED_STATE ]; then
setkeycodes $(cat $SAVED_STATE) || true
fi
;;
restart|force-reload)
$0 stop || true
$0 start
;;
esac
|