From 46c8dce9a24535ae43d0a7086e26da3cf66a36b3 Mon Sep 17 00:00:00 2001
From: Ulrich Sibiller <uli42@gmx.de>
Date: Tue, 5 May 2020 19:29:47 +0200
Subject: Use nxdialog as nxclient replacement

if neither NX_CLIENT ist provided nor /usr/NX/bin/nxclient is existing
try /usr/bin/nxdialog.

Currently the path is hardcoded.
---
 nxcomp/src/Loop.cpp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp
index eb7373f9f..59dd43a10 100644
--- a/nxcomp/src/Loop.cpp
+++ b/nxcomp/src/Loop.cpp
@@ -9842,19 +9842,29 @@ char *GetClientPath()
       //
       // Try to guess the location of the client.
       //
-
-      clientEnv = "/usr/NX/bin/nxclient";
+      // FIXME: replace hardcoded paths by built-time variables if possible
 
       #ifdef __APPLE__
 
       clientEnv = "/Applications/NX Client for OSX.app/Contents/MacOS/nxclient";
 
-      #endif
-
-      #ifdef __CYGWIN32__
+      #else
+      #  if defined(__CYGWIN32__)
 
       clientEnv = "C:\\Program Files\\NX Client for Windows\\nxclient";
 
+      #  else
+
+      clientEnv = "/usr/NX/bin/nxclient";
+
+      struct stat fileStat;
+
+      if ((stat(clientEnv, &fileStat) == -1) && (EGET() == ENOENT))
+      {
+        clientEnv = "/usr/bin/nxdialog";
+      }
+
+      #  endif
       #endif
     }
 
-- 
cgit v1.2.3