From 492c65a32a4ae44c34580ed8ac5d3f50a155cfef Mon Sep 17 00:00:00 2001
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Wed, 11 Apr 2012 14:36:02 +0200
Subject: [PATCH] use own functions file instead /etc/init.d/functions

* so we don't have to depend on initscripts

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>

---
 Makefile             |  1 +
 X11/Xinit.d/11zaurus |  2 +-
 X11/Xinit.d/12keymap |  2 +-
 X11/functions        | 11 +++++++++++
 X11/xserver-common   |  2 +-
 5 files changed, 15 insertions(+), 3 deletions(-)
 create mode 100644 X11/functions

diff --git a/Makefile b/Makefile
index e2d9af9..caa5de1 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ install-program:
 	install -m 755 X11/Xserver $(DESTDIR)/etc/X11/Xserver
 	install -m 755 X11/Xsession $(DESTDIR)/etc/X11/Xsession
 	install -m 755 X11/xserver-common $(DESTDIR)/etc/X11/xserver-common
+	install -m 755 X11/functions $(DESTDIR)/etc/X11/functions
 	install -d $(DESTDIR)/etc/X11/xmodmap
 	install -m 644 X11/xmodmap/*.xmodmap $(DESTDIR)/etc/X11/xmodmap
 	install -m 644 X11/xmodmap/xmodmap-* $(DESTDIR)/etc/X11/xmodmap
diff --git a/X11/Xinit.d/11zaurus b/X11/Xinit.d/11zaurus
index 54ea6f5..23e7713 100644
--- a/X11/Xinit.d/11zaurus
+++ b/X11/Xinit.d/11zaurus
@@ -8,7 +8,7 @@ else
    CHCK=chkhinge
 fi
 
-. /etc/init.d/functions
+. /etc/X11/functions
 
 $CHCK -e
 if [ $? = 12 ]; then
diff --git a/X11/Xinit.d/12keymap b/X11/Xinit.d/12keymap
index 7eac296..b7a7f2d 100644
--- a/X11/Xinit.d/12keymap
+++ b/X11/Xinit.d/12keymap
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-. /etc/init.d/functions
+. /etc/X11/functions
 
 # since kdrive 1.4 there is no default keymap in server
 xmodmap - </etc/X11/xmodmap/default.xmodmap
diff --git a/X11/functions b/X11/functions
new file mode 100644
index 0000000..a1311ad
--- /dev/null
+++ b/X11/functions
@@ -0,0 +1,11 @@
+# -*-Shell-script-*-
+#
+# functions     This file contains functions shared by few X11 scripts
+#               machine_id also exists in /etc/init.d/functions but some
+#               people don't use initscripts anymore
+#
+
+machine_id() { # return the machine ID
+	awk 'BEGIN { FS=": " } /Hardware/ \
+		{ gsub(" ", "_", $2); print tolower($2) } ' </proc/cpuinfo
+}
diff --git a/X11/xserver-common b/X11/xserver-common
index bb7c2ff..d622f2a 100644
--- a/X11/xserver-common
+++ b/X11/xserver-common
@@ -30,7 +30,7 @@ if [ -f /etc/profile ]; then
   . /etc/profile
 fi
 
-. /etc/init.d/functions
+. /etc/X11/functions
 
 fallback_screen_arg() {
     geom=`fbset | grep geometry`
