From 87b6ec150e8954a33bee21f3409ca0e9562c74ad Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Fri, 26 Feb 2021 16:37:03 +0200 Subject: Schedule script: $DISPLAY check. This relates to discussion of issue #22. Signed-off-by: Mavridis Philippe --- src/schedule.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/schedule.cpp b/src/schedule.cpp index 2a89381..75e18b9 100644 --- a/src/schedule.cpp +++ b/src/schedule.cpp @@ -363,8 +363,14 @@ TQString Schedule::createScanScript() ts << "#!/bin/bash" << "\n"; ts << "export HOSTNAME=`hostname`" << "\n"; ts << TQString("export PATH=%1").arg(TQString(getenv("PATH"))) << "\n"; - ts << "export DCOPSERVER=`cat ${HOME}/.DCOPserver_${HOSTNAME}_:0 | grep local`" << "\n"; - ts << "export DISPLAY=:0" << "\n"; + /* The following inspired by https://unix.stackexchange.com/a/17278 */ + ts << "if [ -z \"$DISPLAY\" ]; then" << "\n"; + ts << " for d in /tmp/.X11-unix/X*" << "\n"; + ts << " do" << "\n"; + ts << " export DISPLAY=$(echo $d|sed \"s!/tmp/.X11-unix/X!:!\")" << "\n"; + ts << " done" << "\n"; + ts << "fi" << "\n"; + ts << "export DCOPSERVER=`cat ${HOME}/.DCOPserver_${HOSTNAME}_${DISPLAY} | grep local`" << "\n"; ts << "# Execution starts here" << "\n"; ts << "if [ \"$1\" = \"\" ]; then" << "\n"; ts << " exit 1" << "\n"; -- cgit v1.2.3