--- /usr/portage/x11-wm/pekwm/pekwm-0.1.16.ebuild	2013-01-22 19:59:56.000000000 +0200
+++ /usr/local/portage/x11-wm/pekwm/pekwm-0.1.16-r1.ebuild	2013-01-24 18:56:28.721517861 +0200
@@ -1,11 +1,12 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/x11-wm/pekwm/pekwm-0.1.16.ebuild,v 1.1 2013/01/22 17:59:56 jer Exp $
+# $Header: $
+
+EAPI=4
 
-EAPI=5
 inherit eutils
 
-DESCRIPTION="A small window mananger based on aewm++"
+DESCRIPTION="A lightweight window manager initially based on aewm++"
 HOMEPAGE="http://pekwm.org/"
 SRC_URI="http://pekwm.org/projects/pekwm/files/${P}.tar.bz2
 	mirror://gentoo/${PN}-themes.tar.bz2"
@@ -13,7 +14,7 @@
 LICENSE="GPL-2"
 SLOT="0"
 KEYWORDS="~amd64 ~mips ~ppc ~sparc ~x86 ~x86-fbsd"
-IUSE="debug truetype xinerama"
+IUSE="debug truetype xinerama contrib"
 
 RDEPEND="virtual/jpeg
 	media-libs/libpng
@@ -21,10 +22,16 @@
 	x11-libs/libXrandr
 	x11-libs/libXrender
 	truetype? ( x11-libs/libXft )
-	xinerama? ( x11-libs/libXinerama )"
+	xinerama? ( x11-libs/libXinerama )
+	contrib? (
+			dev-lang/perl
+			gnome-extra/zenity
+	)"
 DEPEND="${RDEPEND}
 	virtual/pkgconfig"
 
+DOCS="README ChangeLog* AUTHORS NEWS"
+	
 src_configure() {
 	econf \
 		$(use_enable debug) \
@@ -40,6 +47,35 @@
 src_install() {
 	default
 
-	rm "${WORKDIR}/themes/Ace/.theme.swp"
-	mv "${WORKDIR}/themes/"* "${D}/usr/share/${PN}/themes/"
+	rm "${WORKDIR}"/themes/Ace/.theme.swp
+	mv "${WORKDIR}"/themes/* "${D}/usr/share/${PN}/themes/"
+	
+	# Insert an Xsession
+	echo -e "#!/bin/sh\n\n/usr/bin/${PN}" > "${T}"/${PN}
+	exeinto /etc/X11/Sessions
+	doexe "${T}"/${PN}
+
+	# Insert a GDM/KDM xsession file
+	make_session_desktop ${PN} ${PN}
+	
+	# Install contributor scripts into doc folder
+	if use contrib ; then
+		rm contrib/lobo/Makefile*
+		
+		docompress -x /usr/share/doc/${PF}/contrib
+		
+		exeinto /usr/share/doc/${PF}/contrib
+		doexe contrib/lobo/*.pl
+		rm contrib/lobo/*.pl
+		
+		docinto contrib
+		dodoc contrib/lobo/*
+	fi
+}
+
+pkg_postinst() {
+	if use contrib ; then
+		elog " User contributed scripts had been installed into: /usr/share/doc/${PF}/contrib"
+		elog " You may find more info about them and their usage in: /usr/share/doc/${PF}/contrib/README"
+	fi
 }