From eb1c6cff914b01732103065781e0ea0cfa225c4e Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 3 Apr 2018 13:03:13 +0200 Subject: Finalize first draft of desktop-autoloader. --- bin/desktop-autoloader | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 bin/desktop-autoloader (limited to 'bin') 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 +# Copyright (C) 2017 Mike Gabriel + +# 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}" & -- cgit v1.2.3