diff --git a/scripts/linuxparty.sh b/scripts/linuxparty.sh
index 72e0684865926fb7933ff5c461d0612545e43321..e8c08f12222482b5e51509133b89ab07b53dc894 100644
--- a/scripts/linuxparty.sh
+++ b/scripts/linuxparty.sh
@@ -6,9 +6,9 @@ set -e
 if [ -z "$GUI" ]; then
   echo "\$GUI is not set. Auto detecting GUI..."
 
-  if command -v zenity 2>&1 > /dev/null; then
+  if command -v zenity 2>&1 > /dev/null && test -n "$DISPLAY"; then
     GUI=zenity
-  elif command -v kdialog 2>&1 > /dev/null; then
+  elif command -v kdialog 2>&1 > /dev/null && test -n "$DISPLAY"; then
     GUI=kdialog
   else
     GUI=none