From 3630efdff2f1151b7b9aeb089b0666ddbeb80a9d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 29 Feb 2024 16:41:46 +0100 Subject: [xorg] Implement has_option in Xsession --- core/modules/xorg/data/etc/X11/Xsession | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/modules/xorg/data/etc/X11/Xsession b/core/modules/xorg/data/etc/X11/Xsession index 33a003ac..0f9f051d 100755 --- a/core/modules/xorg/data/etc/X11/Xsession +++ b/core/modules/xorg/data/etc/X11/Xsession @@ -5,7 +5,7 @@ # Xsession is executed to start the user's session (as the user) # -export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin" +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/openslx/sbin:/opt/openslx/bin" PROGNAME=Xsession @@ -28,6 +28,26 @@ errormsg () { # Make sure we source the global profile - needed for ssh-agent, etc. [ -e "/etc/profile" ] && . "/etc/profile" +# New kid on the block +OPTIONFILE=/etc/X11/Xsession.options +OPTIONS="$( + if [ -r "$OPTIONFILE" ]; then + cat "$OPTIONFILE" + fi + if [ -d /etc/X11/Xsession.options.d ]; then + run-parts --list --regex '\.conf$' /etc/X11/Xsession.options.d | xargs -d '\n' cat + fi +)" + +has_option() { + # Ensure that a later no-foo overrides an earlier foo + if [ "$(echo "$OPTIONS" | grep -Eo "^(no-)?$1\>" | tail -n 1)" = "$1" ]; then + return 0 + else + return 1 + fi +} + # Workaround to start Xsession. The original Xsession script includes error handling functionality and sources other scrips from the Xsession.d/ directory. SESSIONDIR="/etc/X11/Xsession.d" -- cgit v1.2.3-55-g7522