From 2a6d54be85d65653a4272c641e4ac0c8af91dfe5 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Thu, 4 Sep 2025 08:57:09 +0300
Subject: starttde: make adding games to PATH conditional

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 starttde | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/starttde b/starttde
index 85566e973..b73dafd71 100755
--- a/starttde
+++ b/starttde
@@ -214,18 +214,23 @@ if [ "$TDEROOTHOME" = "" ]; then
 fi
 
 # Modify the PATH environment variable only as necessary.
-if ! is_in_path PATH "$TDEDIR/games" ; then
-  # Respect the traditional path order. Don't blindly place $TDEDIR/games
-  # first in the path. Only place $TDEDIR/games before /usr/games. If packagers
-  # are adding $TDEDIR/games elsewhere, then they need to ensure the traditional
-  # search patch is respected.
-  # This order is consistent with tdelibs/tdesu/stub.cpp.
-  # FIXME: Is there a way to check that $TDEDIR/games is always placed only
-  # just before /usr/games in the search path?
-  if is_in_path PATH "/usr/games"; then
-    place_before_in_path PATH "$TDEDIR/games" "/usr/games"
-  else
-    export PATH=$TDEDIR/games:$PATH
+if [ -d /usr/games -o -d "$TDEDIR/games" ] || is_in_path PATH "/usr/games"; then
+  # Some distributions (e.g. Gentoo) don't use a separate directory for games.
+  # So don't add it to PATH unless there are any indications that in might be
+  # actually needed.
+  if ! is_in_path PATH "$TDEDIR/games" ; then
+    # Respect the traditional path order. Don't blindly place $TDEDIR/games
+    # first in the path. Only place $TDEDIR/games before /usr/games. If packagers
+    # are adding $TDEDIR/games elsewhere, then they need to ensure the traditional
+    # search patch is respected.
+    # This order is consistent with tdelibs/tdesu/stub.cpp.
+    # FIXME: Is there a way to check that $TDEDIR/games is always placed only
+    # just before /usr/games in the search path?
+    if is_in_path PATH "/usr/games"; then
+      place_before_in_path PATH "$TDEDIR/games" "/usr/games"
+    else
+      export PATH=$TDEDIR/games:$PATH
+    fi
   fi
 fi
 
-- 
cgit v1.2.3

