aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/desktop-autoloader45
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/desktop-autoloader b/bin/desktop-autoloader
new file mode 100755
index 0000000..0bd5713
--- /dev/null
+++ b/bin/desktop-autoloader
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# Copyright (C) 2011-2017 Klaus Ade Johnstad <klaus@linuxavdelingen.no>
+# Copyright (C) 2017 Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
+
+# This program is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this package; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA
+
+AUTOLOAD_DISPLAY=":20"
+DESKTOP_SESSION_MANAGER="x-session-manager"
+
+test -f /etc/default/desktop-autoloader && . /etc/default/desktop-autoloader
+
+###
+### input sanitizing...
+###
+if ! echo "${AUTOLOAD_DISPLAY}" | grep -qE "^.*:[0-9]+(|\.[0-9]+)"; then
+ echo "Inappropriate setting for \$AUTOLOAD_DISPLAY variable: ${AUTOLOAD_DISPLAY}"
+ exit 1
+fi
+if ! type -p "${DESKTOP_SESSION_MANAGER}" 1>/dev/null; then
+ echo "Cannot find session manager \$DESKTOP_SESSION_MANAGER: ${DESKTOP_SESSION_MANAGER}"
+ exit 1
+fi
+
+# launch an invisible X-Server
+echo Xvfb "${AUTOLOAD_DISPLAY}" &
+
+# launch a session inside this Xserver
+echo DISPLAY=${AUTOLOAD_DISPLAY}
+echo dbus-run-session --exit-with-session "${DESKTOP_SESSION_MANAGER}" &