summaryrefslogtreecommitdiffstats
path: root/src/schedule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/schedule.cpp')
-rw-r--r--src/schedule.cpp10
1 files changed, 8 insertions, 2 deletions
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";