Schedule script: $DISPLAY check.

This relates to discussion of issue #22.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/24/head
Mavridis Philippe 4 years ago
parent cf38aaa0d9
commit 87b6ec150e
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -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";

Loading…
Cancel
Save