[gdm] Xinit: Allow for distros to split system config to /usr/etc



commit d98debd294060489c77d913d32674c4e08987b8f
Author: Dominique Leuenberger <dimstar opensuse org>
Date:   Wed Sep 16 11:59:43 2020 +0200

    Xinit: Allow for distros to split system config to /usr/etc
    
    openSUSE is preparing the system to have /etc as 'administrator config files'
    with system/package config templates shipped in /usr/etc (similar to the
    overlay system used by systemd)
    
    Have gdm follow this and try to load files from /etc, if not existing, fallback
    to /usr/etc

 data/Init.in     | 12 ++++++++++--
 data/Xsession.in | 46 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 49 insertions(+), 9 deletions(-)
---
diff --git a/data/Init.in b/data/Init.in
index 86cc2d86d..0c50251cd 100644
--- a/data/Init.in
+++ b/data/Init.in
@@ -22,14 +22,22 @@ gdmwhich () {
   echo "$OUTPUT"
 }
 
-sysresources=/etc/X11/Xresources
+if [ -f /etc/X11/Xresources ]; then
+    sysresources=/etc/X11/Xresources
+else
+    sysresources=/usr/etc/X11/Xresources
+fi
 
 # merge in defaults
 if [ -f "$sysresources" ]; then
     xrdb -nocpp -merge "$sysresources"
 fi
 
-sysmodmap=/etc/X11/Xmodmap
+if [ -f /etc/X11/Xmodmap ]; then
+    sysmodmap=/etc/X11/Xmodmap
+else
+    sysmodmap=/usr/etc/X11/Xmodmap
+fi
 
 XMODMAP=`gdmwhich xmodmap`
 if [ "x$XMODMAP" != "x" ] ; then
diff --git a/data/Xsession.in b/data/Xsession.in
index 9d79558c3..2e4de4fe3 100755
--- a/data/Xsession.in
+++ b/data/Xsession.in
@@ -29,11 +29,20 @@ command="$@"
 # good for debugging where things went wrong
 echo "$0: Beginning session setup..."
 
-# First read /etc/profile and .profile
-test -f /etc/profile && . /etc/profile
+# First read /etc/profile (resp. /usr/etc/profile) and .profile
+if [ -f /etc/profile ]; then
+  . /etc/profile
+elif [ -f /usr/etc/profile ]; then
+  . /usr/etc/profile
+fi
 test -f "$HOME/.profile" && . "$HOME/.profile"
-# Second read /etc/xprofile and .xprofile for X specific setup
-test -f /etc/xprofile && . /etc/xprofile
+# Second read /etc/xprofile (resp. /usr/etc/xprofile)  and .xprofile for X specific setup
+if [ -f /etc/xprofile ]; then
+  . /etc/xprofile
+elif [ -f /usr/etc/xprofile ]; then
+  . /usr/etc/xprofile
+
+fi
 test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
 
 # Translation stuff
@@ -85,9 +94,23 @@ userresources="$HOME/.Xresources"
 usermodmap="$HOME/.Xmodmap"
 userxkbmap="$HOME/.Xkbmap"
 
-sysresources=/etc/X11/Xresources 
-sysmodmap=/etc/X11/Xmodmap 
-sysxkbmap=/etc/X11/Xkbmap
+if [ -f /etc/X11/Xresources ]; then
+    sysresources=/etc/X11/Xresources
+else
+    sysresources=/usr/etc/X11/Xresources
+fi
+
+if [ -f /etc/X11/Xmodmap ]; then
+    sysmodmap=/etc/X11/Xmodmap
+else
+    sysmodmap=/usr/etc/X11/Xmodmap
+fi
+
+if [ -f /etc/X11/Xkbmap ]; then
+    sysxkbmap=/etc/X11/Xkbmap
+else
+    sysxkbmap=/usr/etc/X11/Xkbmap
+fi
 
 rh6sysresources=/etc/X11/xinit/Xresources 
 rh6sysmodmap=/etc/X11/xinit/Xmodmap 
@@ -149,6 +172,15 @@ unset XKB_IN_USE
 xhost +si:localuser:`id -un` || :
 
 # run all system xinitrc shell scripts.
+if [ -d /usr/etc/X11/xinit/xinitrc.d ]; then
+    for i in /usr/etc/X11/xinit/xinitrc.d/* ; do
+       sname=$(basename "$i")
+        test -x "/etc/X11/xinit/xinitrc.d/$sname" && continue
+        if [ -x "$i" -a ! -d "$i" ]; then
+            . "$i"
+        fi
+    done
+fi
 if [ -d /etc/X11/xinit/xinitrc.d ]; then
     for i in /etc/X11/xinit/xinitrc.d/* ; do
         if [ -x "$i" -a ! -d "$i" ]; then


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]