[X2Go-Commits] [live-build-x2go] 60/108: Trying to completely do away with .xsession file and use modular /etc/X11/Xsession.d config files instead
git-admin at x2go.org
git-admin at x2go.org
Wed Mar 20 22:13:17 CET 2019
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch feature/openbox
in repository live-build-x2go.
commit c48fca4d81e88e3727b8c1079e08599c3f6889a5
Author: Stefan Baur (BAUR-ITCS) <kontakt at baur-itcs.de>
Date: Wed Jan 2 20:59:17 2019 +0100
Trying to completely do away with .xsession file and use modular /etc/X11/Xsession.d config files instead
---
.../etc/X11/Xsession.d/60x11-configure-xinerama | 58 +++++++
.../etc/X11/Xsession.d/61x11-start-x2goclient | 103 ++++++++++++
.../lib/live/config/2900-x2go-thinclientconfig | 181 ---------------------
3 files changed, 161 insertions(+), 181 deletions(-)
diff --git a/config/includes.chroot/etc/X11/Xsession.d/60x11-configure-xinerama b/config/includes.chroot/etc/X11/Xsession.d/60x11-configure-xinerama
new file mode 100644
index 0000000..2fa5356
--- /dev/null
+++ b/config/includes.chroot/etc/X11/Xsession.d/60x11-configure-xinerama
@@ -0,0 +1,58 @@
+# inspired by
+# http://code.x2go.org/gitweb?p=x2gothinclient.git;a=blob_plain;f=displaymanager/sbin/x2gothinclientd;h=6897d42d17bd6778e7de5e62ec3f51727d4e8800;hb=HEAD
+# check the above file for ideas before reinventing the wheel
+
+# additional variable instead of "case $(...) in", as we need the value again later on
+XRANDRCMDTAINTED=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | awk -F '=' '$1 == "xinerama" { print $2 }')
+
+# sanitize input
+case $XRANDRCMDTAINTED in
+"above")
+ XRANDRCMD="above"
+ ;;
+"below")
+ XRANDRCMD="below"
+ ;;
+"same-as")
+ XRANDRCMD="same-as"
+ ;;
+"right-of")
+ XRANDRCMD="right-of"
+ ;;
+*)
+ XRANDRCMD="left-of" # default
+ ;;
+esac
+
+# find out how many touch devices we have
+TOUCHDEVICESCOUNT=$(LANG=C xsetwacom --list devices | wc -l)
+
+# find out how many mouse devices we have
+MICECOUNT=$(find /dev/input -maxdepth 1 -name "mouse*" | wc -l)
+
+# loop through the following code block for all connected display devices
+for NEXT_DISPLAY in $(LANG=C xrandr 2>/dev/null | grep ' connected ' | cut -d ' ' -f1); do
+
+ #remove trailing newline from NEXT_DISPLAY
+ NEXT_DISPLAY=${NEXT_DISPLAY%$'\n'}
+
+ # THIS_DISPLAY won't be defined until the second time the loop is executed, which is a
+ # neat way of running xrandr only if there are at least two connected display devices
+ if [ -n "${THIS_DISPLAY+x}" ] ; then
+
+ if [ $TOUCHDEVICESCOUNT -gt 0 ] && [ $MICECOUNT -lt 1 ] && [ -z $XRANDRCMDTAINTED ]; then
+ # we have a touch device and no mice, and no xinerama parameter was set,
+ # so switch to clone view to make the touch device usable
+ /usr/bin/xrandr --output $NEXT_DISPLAY --same-as $THIS_DISPLAY
+
+ else
+ # else use whatever is in XRANDRCMD (which is either our default of "left-of",
+ # or a valid xinerama kernel parameter value)
+ /usr/bin/xrandr --output $NEXT_DISPLAY --$XRANDRCMD $THIS_DISPLAY
+ fi
+
+ fi
+ # now set THIS_DISPLAY -> every subsequent iteration of the loop will now enter the code block
+ # above where [ -n ${THIS_DISPLAY+x} ] is the conditional
+ THIS_DISPLAY=$NEXT_DISPLAY
+done
diff --git a/config/includes.chroot/etc/X11/Xsession.d/61x11-start-x2goclient b/config/includes.chroot/etc/X11/Xsession.d/61x11-start-x2goclient
new file mode 100644
index 0000000..e22b47e
--- /dev/null
+++ b/config/includes.chroot/etc/X11/Xsession.d/61x11-start-x2goclient
@@ -0,0 +1,103 @@
+# Get X2GoConfig
+BROKERURL=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | awk -F'=' ' /^broker-url=/ { print $2 }' | tr -dc 'a-zA-Z0-9.:/?%_\-@')
+SESSIONSELECT=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | awk -F'=' ' /^session=/ { print $2 }' | tr -dc 'a-zA-Z0-9.:/ _\-@')
+LDAP=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | sed 's/^ldap=/ldap#/' | awk -F'#' ' /^ldap#/ { print $2 }' | tr -dc 'a-zA-Z0-9.:_\-@')
+LDAP1=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | sed 's/^ldap1=/ldap1#/' | awk -F'#' ' /^ldap1#/ { print $2 }' | tr -dc 'a-zA-Z0-9.:_\-@')
+LDAP2=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | sed 's/^ldap2=/ldap2#/' | awk -F'#' ' /^ldap2#/ { print $2 }' | tr -dc 'a-zA-Z0-9.:_\-@')
+
+
+# Check for background and branding SVGs
+BRANDING=''
+OLDCON=''
+if grep -q ' branding=' /proc/cmdline; then
+ while ! [ -s "/etc/x2go/branding.svg" ]; do
+ [ -z "$OLDCON" ] && OLDCON="$(fgconsole)"
+ chvt "1"
+ echo "'$0' is waiting for a valid '/etc/x2go/branding.svg' file."
+ sleep "2"
+ done
+ [ -n "$OLDCON" ] && chvt "$OLDCON"
+ BRANDING='--branding=/etc/x2go/branding.svg'
+fi
+BACKGROUND=''
+OLDCON=''
+if grep -q ' bg=' /proc/cmdline; then
+ while ! [ -s "/etc/x2go/bg.svg" ]; do
+ [ -z "$OLDCON" ] && OLDCON="$(fgconsole)"
+ chvt "1"
+ echo "'$0' is waiting for a valid '/etc/x2go/bg.svg' file."
+ sleep "2"
+ done
+ [ -n "$OLDCON" ] && chvt "$OLDCON"
+ BACKGROUND='--background=/etc/x2go/bg.svg'
+fi
+
+# Spawn X2GoClient
+if [ -n "$SESSIONSELECT" ]; then
+ STARTSESSION="--session='$SESSIONSELECT'"
+fi
+if [ -n "$BROKERURL" ]; then
+ SESSIONFROM="--broker-url=$BROKERURL"
+else
+ SESSIONFROM="--session-conf=/etc/x2go/x2gothinclient_sessions"
+ OLDCON=''
+ while ! [ -s "/etc/x2go/x2gothinclient_sessions" ]; do
+ [ -z "$OLDCON" ] && OLDCON="$(fgconsole)"
+ chvt "1"
+ echo "'$0' is waiting for a valid '/etc/x2go/x2gothinclient_sessions' file."
+ sleep "2"
+ done
+ [ -n "$OLDCON" ] && chvt "$OLDCON"
+fi
+if [ -n "$LDAP" ] ; then
+ if [ -n "$LDAP1" ] ; then
+ BACKUPLDAP="--ldap1=$LDAP1"
+ if [ -n "$LDAP2" ] ; then
+ BACKUPLDAP="$BACKUPLDAP --ldap2=$LDAP2"
+ fi
+ fi
+ LDAPPARAMS="--ldap=$LDAP $BACKUPLDAP"
+else
+ LDAPPARAMS=""
+fi
+
+
+THROTTLINGCOMMAND=""
+THROTTLEVALUES=$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | awk -F '=' '$1 == "throttle" { print $2 }' | tr -dc '0-9.:u')
+if [ -n "$THROTTLEVALUES" ]; then
+ # determine maximum line speed
+ # look for all interfaces in state "up", then read their speed value from the file named speed
+ # just ignore the output if there is none, then sort numeric, unique, and read last line=highest,
+ # then sanitize
+ MAXSPEEDMBIT=$(grep -l "up" /sys/class/net/*/operstate | xargs -n1 dirname | xargs -n 1 -I XXX cat XXX/speed 2>/dev/null | sort -n -u | tail -1 | tr -dc '0-9.')
+ MAXSPEEDKBYTE=$((MAXSPEEDMBIT*128)) #Megabit * 1024 / 8 -> KiloByte
+
+ THROTTLEARR=($(echo $THROTTLEVALUES | awk -F ':' '$1 ~/^[0-9\.u]*$/ && $2 ~/^[0-9\.u]*$/ && $3 ~/^[0-9\.u]*$/ && $4 ~/^[0-9\.u]*$/ && $4 ~/^[0-9\.u]*$/ { print $1 " " $2 " " $3 " " $4 " " $5}'))
+ if [ -n "${THROTTLEARR[0]}" ] && [ "${THROTTLEARR[0]}" != "u" ]; then
+ THROTTLEDOWN="-d ${THROTTLEARR[0]}" # default 10, never used
+ elif [ "${THROTTLEARR[0]}" = "u" ]; then
+ THROTTLEDOWN="-d $MAXSPEEDKBYTE"
+ fi
+ if [ -n "${THROTTLEARR[1]}" ] && [ "${THROTTLEARR[1]}" != "u" ]; then
+ THROTTLEUP="-u ${THROTTLEARR[1]}" # default 10, never used
+ elif [ "${THROTTLEARR[1]}" = "u" ]; then
+ THROTTLEUP="-d $MAXSPEEDKBYTE"
+ elif [ -z "${THROTTLEARR[1]}" ] ; then
+ THROTTLEUP="-d ${THROTTLEARR[0]}" # set up=down if only 1 param
+ fi
+ if [ -n "${THROTTLEARR[2]}" ] ; then
+ THROTTLETIME="-t ${THROTTLEARR[2]}" # default 3.0
+ fi
+ if [ -n "${THROTTLEARR[3]}" ] ; then
+ THROTTLELENGTH="-l ${THROTTLEARR[3]}" # default 20
+ fi
+ if [ -n "${THROTTLEARR[4]}" ] ; then
+ THROTTLELATENCY="-L ${THROTTLEARR[4]}" # default 0
+ fi
+ # only set THROTTLINGCOMMAND if at least one value was detected and sanitized properly
+ if [ -n "$THROTTLEUP" ] || [ -n "$THROTTLEDOWN" ] || [ -n "$THROTTLETIME" ] || [ -n "$THROTTLELENGTH" ] || [ -n "$THROTTLELATENCY" ]; then
+ THROTTLINGCOMMAND="trickle -s $THROTTLEDOWN $THROTTLEUP $THROTTLETIME $THROTTLELENGTH $THROTTLELATENCY"
+ fi
+fi
+
+eval $THROTTLINGCOMMAND x2goclient --thinclient --no-session-edit --no-menu --maximize --add-to-known-hosts --haltbt --read-exports-from=/home/user/export $LDAPPARAMS $SESSIONFROM $BACKGROUND $BRANDING $STARTSESSION
diff --git a/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig b/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
index 9685d8a..bce0cc7 100755
--- a/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
+++ b/config/includes.chroot/lib/live/config/2900-x2go-thinclientconfig
@@ -19,187 +19,6 @@ sed -i -e '\#<applications>#a<application title="X2Go Client" type="normal">' -e
#make sure OpenBox' ToggleMaximize is disabled, or else clicking the top row of pixels will un-maximize X2GoClient
sed -i -e '/ToggleMaximize/d' /etc/xdg/openbox/rc.xml
-cat >/home/user/.xsession <<XSESSION
-# inspired by
-# http://code.x2go.org/gitweb?p=x2gothinclient.git;a=blob_plain;f=displaymanager/sbin/x2gothinclientd;h=6897d42d17bd6778e7de5e62ec3f51727d4e8800;hb=HEAD
-# check the above file for ideas before reinventing the wheel
-
-# additional variable instead of "case \$(...) in", as we need the value again later on
-XRANDRCMDTAINTED=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | awk -F '=' '\$1 == "xinerama" { print \$2 }')
-
-# sanitize input
-case \$XRANDRCMDTAINTED in
-"above")
- XRANDRCMD="above"
- ;;
-"below")
- XRANDRCMD="below"
- ;;
-"same-as")
- XRANDRCMD="same-as"
- ;;
-"right-of")
- XRANDRCMD="right-of"
- ;;
-*)
- XRANDRCMD="left-of" # default
- ;;
-esac
-
-# find out how many touch devices we have
-TOUCHDEVICESCOUNT=\$(LANG=C xsetwacom --list devices | wc -l)
-
-# find out how many mouse devices we have
-MICECOUNT=\$(find /dev/input -maxdepth 1 -name "mouse*" | wc -l)
-
-# loop through the following code block for all connected display devices
-for NEXT_DISPLAY in \$(LANG=C xrandr 2>/dev/null | grep ' connected ' | cut -d ' ' -f1); do
-
- #remove trailing newline from NEXT_DISPLAY
- NEXT_DISPLAY=\${NEXT_DISPLAY%\$'\n'}
-
- # THIS_DISPLAY won't be defined until the second time the loop is executed, which is a
- # neat way of running xrandr only if there are at least two connected display devices
- if [ -n "\${THIS_DISPLAY+x}" ] ; then
-
- if [ \$TOUCHDEVICESCOUNT -gt 0 ] && [ \$MICECOUNT -lt 1 ] && [ -z \$XRANDRCMDTAINTED ]; then
- # we have a touch device and no mice, and no xinerama parameter was set,
- # so switch to clone view to make the touch device usable
- /usr/bin/xrandr --output \$NEXT_DISPLAY --same-as \$THIS_DISPLAY
-
- else
- # else use whatever is in XRANDRCMD (which is either our default of "left-of",
- # or a valid xinerama kernel parameter value)
- /usr/bin/xrandr --output \$NEXT_DISPLAY --\$XRANDRCMD \$THIS_DISPLAY
- fi
-
- fi
- # now set THIS_DISPLAY -> every subsequent iteration of the loop will now enter the code block
- # above where [ -n \${THIS_DISPLAY+x} ] is the conditional
- THIS_DISPLAY=\$NEXT_DISPLAY
-done
-
-# Get X2GoConfig
-BROKERURL=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | \
- awk -F'=' ' /^broker-url=/ { print \$2 }' | \
- tr -dc 'a-zA-Z0-9.:/?%_\-@')
-SESSIONSELECT=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | \
- awk -F'=' ' /^session=/ { print \$2 }' | \
- tr -dc 'a-zA-Z0-9.:/ _\-@')
-LDAP=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | \
- sed 's/^ldap=/ldap#/' | \
- awk -F'#' ' /^ldap#/ { print \$2 }' | \
- tr -dc 'a-zA-Z0-9.:_\-@')
-LDAP1=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | \
- sed 's/^ldap1=/ldap1#/' | \
- awk -F'#' ' /^ldap1#/ { print \$2 }' | \
- tr -dc 'a-zA-Z0-9.:_\-@')
-LDAP2=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | \
- sed 's/^ldap2=/ldap2#/' | \
- awk -F'#' ' /^ldap2#/ { print \$2 }' | \
- tr -dc 'a-zA-Z0-9.:_\-@')
-
-
-# Check for background and branding SVGs
-BRANDING=''
-OLDCON=''
-if grep -q ' branding=' /proc/cmdline; then
- while ! [ -s "/etc/x2go/branding.svg" ]; do
- [ -z "\$OLDCON" ] && OLDCON="\$(fgconsole)"
- chvt "1"
- echo "'\$0' is waiting for a valid '/etc/x2go/branding.svg' file."
- sleep "2"
- done
- [ -n "\$OLDCON" ] && chvt "\$OLDCON"
- BRANDING='--branding=/etc/x2go/branding.svg'
-fi
-BACKGROUND=''
-OLDCON=''
-if grep -q ' bg=' /proc/cmdline; then
- while ! [ -s "/etc/x2go/bg.svg" ]; do
- [ -z "\$OLDCON" ] && OLDCON="\$(fgconsole)"
- chvt "1"
- echo "'\$0' is waiting for a valid '/etc/x2go/bg.svg' file."
- sleep "2"
- done
- [ -n "\$OLDCON" ] && chvt "\$OLDCON"
- BACKGROUND='--background=/etc/x2go/bg.svg'
-fi
-
-# Spawn X2GoClient
-if [ -n "\$SESSIONSELECT" ]; then
- STARTSESSION="--session='\$SESSIONSELECT'"
-fi
-if [ -n "\$BROKERURL" ]; then
- SESSIONFROM="--broker-url=\$BROKERURL"
-else
- SESSIONFROM="--session-conf=/etc/x2go/x2gothinclient_sessions"
- OLDCON=''
- while ! [ -s "/etc/x2go/x2gothinclient_sessions" ]; do
- [ -z "\$OLDCON" ] && OLDCON="\$(fgconsole)"
- chvt "1"
- echo "'\$0' is waiting for a valid '/etc/x2go/x2gothinclient_sessions' file."
- sleep "2"
- done
- [ -n "\$OLDCON" ] && chvt "\$OLDCON"
-fi
-if [ -n "\$LDAP" ] ; then
- if [ -n "\$LDAP1" ] ; then
- BACKUPLDAP="--ldap1=\$LDAP1"
- if [ -n "\$LDAP2" ] ; then
- BACKUPLDAP="\$BACKUPLDAP --ldap2=\$LDAP2"
- fi
- fi
- LDAPPARAMS="--ldap=\$LDAP \$BACKUPLDAP"
-else
- LDAPPARAMS=""
-fi
-
-
-THROTTLINGCOMMAND=""
-THROTTLEVALUES=\$(sed -e 's/ \([^ ]*\)=/\n\1=/g' -e 's/\([^=]["'"'"']\) /\1\n/g' -e 's/ \([^ "'"'"']\)/\n\1/g' /proc/cmdline | awk -F '=' '\$1 == "throttle" { print \$2 }' | tr -dc '0-9.:u')
-if [ -n "\$THROTTLEVALUES" ]; then
- # determine maximum line speed
- # look for all interfaces in state "up", then read their speed value from the file named speed
- # just ignore the output if there is none, then sort numeric, unique, and read last line=highest,
- # then sanitize
- MAXSPEEDMBIT=\$(grep -l "up" /sys/class/net/*/operstate | xargs -n1 dirname | xargs -n 1 -I XXX cat XXX/speed 2>/dev/null | sort -n -u | tail -1 | tr -dc '0-9.')
- MAXSPEEDKBYTE=\$((MAXSPEEDMBIT*128)) #Megabit * 1024 / 8 -> KiloByte
-
- THROTTLEARR=(\$(echo \$THROTTLEVALUES | awk -F ':' '\$1 ~/^[0-9\.u]*\$/ && \$2 ~/^[0-9\.u]*\$/ && \$3 ~/^[0-9\.u]*\$/ && \$4 ~/^[0-9\.u]*\$/ && \$4 ~/^[0-9\.u]*\$/ { print \$1 " " \$2 " " \$3 " " \$4 " " \$5}'))
- if [ -n "\${THROTTLEARR[0]}" ] && [ "\${THROTTLEARR[0]}" != "u" ]; then
- THROTTLEDOWN="-d \${THROTTLEARR[0]}" # default 10, never used
- elif [ "\${THROTTLEARR[0]}" = "u" ]; then
- THROTTLEDOWN="-d \$MAXSPEEDKBYTE"
- fi
- if [ -n "\${THROTTLEARR[1]}" ] && [ "\${THROTTLEARR[1]}" != "u" ]; then
- THROTTLEUP="-u \${THROTTLEARR[1]}" # default 10, never used
- elif [ "\${THROTTLEARR[1]}" = "u" ]; then
- THROTTLEUP="-d \$MAXSPEEDKBYTE"
- elif [ -z "\${THROTTLEARR[1]}" ] ; then
- THROTTLEUP="-d \${THROTTLEARR[0]}" # set up=down if only 1 param
- fi
- if [ -n "\${THROTTLEARR[2]}" ] ; then
- THROTTLETIME="-t \${THROTTLEARR[2]}" # default 3.0
- fi
- if [ -n "\${THROTTLEARR[3]}" ] ; then
- THROTTLELENGTH="-l \${THROTTLEARR[3]}" # default 20
- fi
- if [ -n "\${THROTTLEARR[4]}" ] ; then
- THROTTLELATENCY="-L \${THROTTLEARR[4]}" # default 0
- fi
- # only set THROTTLINGCOMMAND if at least one value was detected and sanitized properly
- if [ -n "\$THROTTLEUP" ] || [ -n "\$THROTTLEDOWN" ] || [ -n "\$THROTTLETIME" ] || [ -n "\$THROTTLELENGTH" ] || [ -n "\$THROTTLELATENCY" ]; then
- THROTTLINGCOMMAND="trickle -s \$THROTTLEDOWN \$THROTTLEUP \$THROTTLETIME \$THROTTLELENGTH \$THROTTLELATENCY"
- fi
-fi
-
-eval \$THROTTLINGCOMMAND x2goclient --thinclient --no-session-edit --no-menu --maximize --add-to-known-hosts --haltbt --read-exports-from=/home/user/export \$LDAPPARAMS \$SESSIONFROM \$BACKGROUND \$BRANDING \$STARTSESSION
-XSESSION
-
-chown user:user /home/user/.xsession
-chmod 644 /home/user/.xsession
-
# This is needed for File Sharing support (USB media and the like)
mkdir -p /home/user/{export,logins,mounts}
chown user:user /home/user/{export,logins,mounts}
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/live-build-x2go.git
More information about the x2go-commits
mailing list