jong357 |
12-18-2006 10:51 PM |
mbpeventd
I found a new prog that is MUCH better at handling the specific function keys on a macbook.
http://www.technologeek.org/projects/pommed/index.html
LCD backlight, Keyboard backlight, volume keys and the eject key work with it. This makes the macbook-tools package obsolete so pick one or the other. I'm still using xkbset/xbindkeys to have the F12 mount cd's and for the right-click on the right-apple key. But atleast the others are handled more properly now.
And, just like the other macbook-tools script, it makes a monolithic package. Bust it up if that bothers you.
Code:
#!/bin/sh
#
# http://linux.dell.com/libsmbios/main/index.html
# http://www.nongnu.org/confuse/
# http://www.technologeek.org/projects/pommed/index.html
# EXTRAS:
# http://hocwp.free.fr/xbindkeys/xbindkeys.html
# http://www.math.missouri.edu/~stephen/software/
# OLD:
# http://www.boichat.ch/nicolas/macbook-tools/
CWD=`pwd`
TMP=/tmp
PKGNAME=pommed
PKG=$TMP/package-$PKGNAME
VERSION=1.1
LIBSMBIOS=0.12.4
CONFUSE=2.5
XKBSET=0.5
XBINDKEYS=1.7.3
PKGVER=${VERSION}
ARCH=i486
BUILD=1
# This will make the right-apple key a 'right-click',
# the F12 a 'mount cd' and install a wrapper
# script for cpufreq-selector...
#
# If EXTRAS=no then all variables after $EXTRAS
# won't get used...
EXTRAS=yes
HOMEDIR=/root
X11_PREFIX=/usr/X11R6
# Select the CPU frequency governer you wish to use. Available options are:
# performance, powersave, ondemand, conservative and userspace.
GOVERNER=ondemand
rm -rf $PKG
mkdir -p $PKG/{install,etc/rc.d,usr/{sbin,man/man1}}
if [ -a /var/log/packages/pommed-* ]; then
echo
echo "Removing existing package..."
removepkg /var/log/packages/pommed-* > /dev/null 2>&1
fi
# Build libsmbios first:
cd $TMP
echo
echo "libsmbios-$LIBSMBIOS source is now extracting..."
rm -rf libsmbios-$LIBSMBIOS
tar xjf $CWD/source/libsmbios-$LIBSMBIOS.tar.bz2
cd libsmbios-$LIBSMBIOS
chown -R root.root .
make
cp -Ra {include,lib.unloaded} $PKG/usr
mv $PKG/usr/lib.unloaded $PKG/usr/lib
# I'll leave out the bin progs for now..
find $PKG -type f -name *.h -exec chmod 644 {} \;
find $PKG -type f -name *.hpp -exec chmod 644 {} \;
# Now build confuse:
cd $TMP
echo
echo "confuse-$CONFUSE source is now extracting..."
rm -rf confuse-$CONFUSE
tar xzf $CWD/source/confuse-$CONFUSE.tar.gz
cd confuse-$CONFUSE
chown -R root.root .
./configure --prefix=/usr \
--enable-shared \
--disable-static
make
make install DESTDIR=$PKG
rm -rf $PKG/usr/bin
# Build the temp package:
cd $PKG
echo "# Begin Symlinks:" > $PKG/install/doinst.sh
makepkg -l y -c n $TMP/aaa-temp-pommed.tgz > /dev/null 2>&1
installpkg $TMP/aaa-temp-pommed.tgz > /dev/null 2>&1
cd $TMP
echo
echo "$PKGNAME-$VERSION source is now extracting..."
rm -rf $PKGNAME-$VERSION
tar xzf $CWD/source/$PKGNAME-$VERSION.tar.gz
cd $PKGNAME-$VERSION
chown -R root.root .
cd src
make pommed
mkdir -p $PKG/etc/dbus-1/system.d
install -m 755 pommed/pommed $PKG/usr/sbin
install -m 644 pommed.1 $PKG/usr/man/man1
install -m 644 pommed.conf $PKG/etc
install -m 644 dbus-policy.conf $PKG/etc/dbus-1/system.d/pommed.conf
make gpomme
mkdir -p $PKG/usr/share/{applications,gpomme,locale/{de,es,fr}/LC_MESSAGES}
install -m 755 gpomme/gpomme $PKG/usr/sbin
cp -R gpomme/themes $PKG/usr/share/gpomme
install -m 644 gpomme/po/de.mo $PKG/usr/share/locale/de/LC_MESSAGES/gpomme.mo
install -m 644 gpomme/po/es.mo $PKG/usr/share/locale/es/LC_MESSAGES/gpomme.mo
install -m 644 gpomme/po/fr.mo $PKG/usr/share/locale/fr/LC_MESSAGES/gpomme.mo
install -m 644 gpomme/gpomme.desktop $PKG/usr/share/applications
# gpomme session start:
mkdir -p $PKG/usr/share/gnome/autostart
cat << EOF > $PKG/usr/share/gnome/autostart/gpomme.desktop
[Desktop Entry]
Name=gpomme
Encoding=UTF-8
Version=1.0
Icon=
Exec=/usr/sbin/gpomme
X-GNOME-Autostart-enabled=true
EOF
# Startup script:
if [ -a /etc/slackware-version ]; then
install -m 755 $CWD/rc.pommed $PKG/etc/rc.d
echo '# Append to rc.local if not found, commented or not:
if ! grep rc.pommed etc/rc.d/rc.local 1> /dev/null 2> /dev/null ; then
echo "# Added by POMMED install:
if [ -x /etc/rc.d/rc.pommed ]; then
/etc/rc.d/rc.pommed start
fi" >> etc/rc.d/rc.local
fi' >> $PKG/install/doinst.sh
elif [ -a /etc/jaguar-version ]; then
mkdir -p $PKG/etc/rc.d/init.d
# Finish me
fi
# Remove the temp package:
removepkg $TMP/aaa-temp-pommed.tgz > /dev/null 2>&1
rm -f $TMP/aaa-temp-pommed.tgz
if [ "$EXTRAS" = "yes" ]; then
mkdir -p $PKG/usr/bin
cd $TMP
echo
echo "xbindkeys-$XBINDKEYS source is now extracting..."
rm -rf xbindkeys-$XBINDKEYS
tar xzf $CWD/source/xbindkeys-$XBINDKEYS.tar.gz
cd xbindkeys-$XBINDKEYS
chown -R root.root .
# It's crapping out on guile. We don't need it anyway.
./configure --prefix=$X11_PREFIX \
--disable-guile
make
make install DESTDIR=$PKG
# Add a wrapper script for mount:
cat << EOF > $PKG/usr/bin/macmount
#!/bin/sh
if ! mount | grep /dev/hda 2>/dev/null 1>/dev/null ;then
mount /dev/hda /mnt/cdrom
fi
EOF
chmod 755 $PKG/usr/bin/macmount
# Add a wrapper script for eject:
cat << EOF > $PKG/usr/bin/maceject
#!/bin/sh
if mount | grep /dev/hda 2>/dev/null 1>/dev/null ;then
umount /dev/hda
fi
eject /dev/hda
EOF
chmod 755 $PKG/usr/bin/maceject
# Throw a ~/.xbindkeysrc and in /usr/doc
# We could also put .xbindkeysrc in $PKG/etc/skel...
mkdir -p $PKG/usr/doc/xbindkeys-$XBINDKEYS
cat << EOF > $PKG/usr/doc/xbindkeys-$XBINDKEYS/.xbindkeysrc
###########################
# xbindkeys configuration #
###########################
#
# If you edit this file, do not forget to uncomment any lines
# that you change.
# The pound(#) symbol may be used anywhere for comments.
#
# To specify a key, you can use 'xbindkeys --key' or
# 'xbindkeys --multikey' and put one of the two lines in this file.
#
# The format of a command line is:
# "command to start"
# associated key
#
#
# A list of keys is in $X11_PREFIX/include/X11/keysym.h and in
# $X11_PREFIX/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier:
# Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock),
# Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#
# The release modifier is not a standard X modifier, but you can
# use it if you want to catch release events instead of press events
# By defaults, xbindkeys does not pay attention with the modifiers
# NumLock, CapsLock and ScrollLock.
# Uncomment the lines above if you want to pay attention to them.
#keystate_numlock = enable
#keystate_capslock = enable
#keystate_scrolllock= enable
# Run "xbindkeys --multikey" for the keycode of multiple key presses
# Run "xbindkeys --key" for the keycode of a single key press
#################
# Mac Book Pro: #
#################
# The commented options are for soley using xbindkeys
# WITHOUT pommed running... If your doing that, then
# you'll need the 'applesmc' and 'backlight' binaries in
# your $PATH...
# [fn]+[F1] Lower LCD backlight by a factor of 10
#"backlight -10"
# m:0x0 + c:67
# [fn]+[F2] Raise LCD backlight by a factor of 10
#"backlight +10"
# m:0x0 + c:68
# [fn]+[F8] Turn Keyboard backlight OFF
#"applesmc 0"
# m:0x0 + c:74
# [fn]+[F9] Turn Keyboard backlight ON HALFWAY
#"applesmc 127"
# m:0x0 + c:75
# [fn]+[F10] Turn Keyboard backlight ON all the way
#"applesmc 255"
# m:0x0 + c:76
# Top right eject key ( next to [F12] )
#"maceject"
# m:0x0 + c:204
# Might as well have a mount key too for us non-hal users [F12]
"macmount"
m:0x0 + c:96
##################################
# End of xbindkeys configuration #
##################################
EOF
# Wrapper script for cpufreq-selector and GNOME autostart:
cat << EOF > $PKG/usr/bin/cpufreq
#!/bin/sh
#
# This is a wrapper script for 'cpufreq-selector'.
# The second processor doesn't respond to user calls via
# applets or directly thru cpufreq-selector. It's a hack
# to set both procs with the same governer at once.
CLONE="cp /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor"
# Load all the modules:
if ! lsmod | grep speedstep_centrino 2>/dev/null 1>/dev/null ;then
modprobe speedstep_centrino > /dev/null 2>&1
modprobe cpufreq_conservative > /dev/null 2>&1
modprobe cpufreq_ondemand > /dev/null 2>&1
modprobe cpufreq_powersave > /dev/null 2>&1
modprobe cpufreq_userspace > /dev/null 2>&1
modprobe cpufreq_stats > /dev/null 2>&1
modprobe freq_table > /dev/null 2>&1
fi
case "@1" in
performance)
cpufreq-selector -c 0 -g performance
@CLONE
;;
powersave)
cpufreq-selector -c 0 -g powersave
@CLONE
;;
ondemand)
cpufreq-selector -c 0 -g ondemand
@CLONE
;;
conservative)
cpufreq-selector -c 0 -g conservative
@CLONE
;;
userspace)
cpufreq-selector -c 0 -g userspace
@CLONE
;;
*)
echo "Usage: @0 {performance|powersave|ondemand|conservative|userspace}"
exit 1
;;
esac
EOF
sed -i 's/@/$/' $PKG/usr/bin/cpufreq
chmod 755 $PKG/usr/bin/cpufreq
mkdir -p $PKG/usr/share/gnome/autostart
cat << EOF > $PKG/usr/share/gnome/autostart/cpufreq.desktop
[Desktop Entry]
Name=cpufreq
Encoding=UTF-8
Version=1.0
Icon=/usr/share/icons/hicolor/32x32/apps/gnome-cpu-frequency-applet.png
Exec=/usr/bin/cpufreq $GOVERNER
X-GNOME-Autostart-enabled=true
EOF
mkdir -p $PKG/$X11_PREFIX/{bin,man/man1}
cd $TMP
echo
echo "xkbset-$XKBSET source is now extracting..."
rm -rf xkbset-$XKBSET
tar xzf $CWD/source/xkbset-$XKBSET.tar.gz
cd xkbset-$XKBSET
chown -R root.root .
if [ "$X11_PREFIX" = "/usr" ]; then
sed -i 's@usr/X11R6@usr@' Makefile
fi
make
make install DESTDIR=$PKG
# Wrapper script:
cat << EOF > $PKG/usr/bin/right-click
#!/bin/sh
xmodmap -e 'keycode 116 = Pointer_Button3'
xkbset m
EOF
chmod 755 $PKG/usr/bin/right-click
# Throw the xbindkeys config in your home directory:
if [ "$HOMEDIR" = "/root" ]; then
install -d $PKG/root -m 0750
else
mkdir -p $PKG/$HOMEDIR
fi
cp $PKG/usr/doc/xbindkeys-$XBINDKEYS/.xbindkeysrc $PKG/$HOMEDIR
# Now add both startup programs to Gnome:
mkdir -p $PKG/usr/share/gnome/autostart
cat << EOF > $PKG/usr/share/gnome/autostart/xbindkeys.desktop
[Desktop Entry]
Name=xbindkeys
Encoding=UTF-8
Version=1.0
Icon=gnome-settings-accessibility-keyboard
Exec=$X11_PREFIX/bin/xbindkeys
X-GNOME-Autostart-enabled=true
EOF
cat << EOF > $PKG/usr/share/gnome/autostart/right-click.desktop
[Desktop Entry]
Name=right-click
Encoding=UTF-8
Version=1.0
Icon=gnome-dev-mouse-optical
Exec=/usr/bin/right-click
X-GNOME-Autostart-enabled=true
EOF
fi
# Fix info dir
if test $PKGNAME = texinfo; then
true
else
rm $PKG/usr/info/dir
fi
# Compress and strip
gzip -9 $PKG/usr/man/man?/*.?
gzip -9 $PKG/$X11_PREFIX/man/man?/*.?
( cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null )
# Make the package description:
cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler-----------------------------------------------------|
pommed: pommed (macbook hot keys)
pommed:
pommed: pommed is an event handler daemon for the hotkeys found on the
pommed: MacBook Pro. It also handles the keyboard backlight, turning it on
pommed: automatically when the ambient light is low.
pommed:
pommed:
pommed:
pommed:
pommed:
pommed:
EOF
# Build the package:
cd $PKG
makepkg -l y -c n $TMP/$PKGNAME-$PKGVER-$ARCH-$BUILD.tgz
Here is $CWD/rc.pommed
Code:
#!/bin/sh
#
# /etc/rc.d/rc.pommed
PIDFILE=/var/run/pommed.pid
POMMED=/usr/sbin/pommed
pommed_start() {
# Just in case
if [ -e "$PIDFILE" ]; then
rm -f $PIDFILE
fi
if ! lsmod | grep applesmc 2>/dev/null 1>/dev/null ;then
modprobe applesmc
fi
echo "Starting Macbook Pro event daemon: $POMMED"
$POMMED
}
pommed_status() {
local pidlist=`cat $PIDFILE 2>/dev/null`
if [ -z "$pidlist" ]; then
return 1
fi
local command=`ps -p $pidlist -o comm=`
if [ "$command" != 'pommed' ]; then
return 1
fi
}
pommed_stop() {
echo -en "Stopping Macbook Pro event daemon: ";
local pidlist=`cat $PIDFILE 2>/dev/null`
if [ ! -z "$pidlist" ]; then
kill $pidlist &>/dev/null
rm -f $PIDFILE &>/dev/null
fi
echo "stopped";
}
pommed_restart() {
pommed_stop
sleep 1
pommed_start
}
case "$1" in
'start')
if ( ! pommed_status ); then
pommed_start
else
echo "Macbook Pro event daemon is already running..."
fi
;;
'stop')
pommed_stop;
;;
'restart')
pommed_restart;
;;
'status')
if ( pommed_status ); then
echo "Macbook Pro event daemon is currently running."
else
echo "Macbook Pro event daemon is not running."
fi
;;
*)
echo "usage $0 start|stop|status|restart";
esac
Here is a list of $CWD/patches
Code:
applesmc.patch
ir.patch
Those need to be applied to the kernel and can be found at
http://svn.sourceforge.net/viewvc/ma...atches-2.6.18/
You really only need the applesmc patch but there is an infared option in /etc/mbpeventd.conf which will require the ir.patch... The only thing that doesn't work out-of-the-box is the mute key while using the speakers. The mute key does work when using headphones however. There are options for changing the mute elements, again, in /etc/mbpeventd.conf....
And finally, here is a listing of $CWD/source
Code:
confuse-2.5.tar.gz
libsmbios-0.12.4.tar.bz2
pommed-1.1.tar.gz
xbindkeys-1.7.3.tar.gz
xkbset-0.5.tar.gz
I'll tar all of the above, including source, and make it available at my file server here in abit.
http://jaguarlinux.com/pub/slackware/source/macbookpro/
|