From fcb9a3f3dbfe55276d1d7b4eb4ec563226429adf Mon Sep 17 00:00:00 2001
From: Martino Facchin <m.facchin@arduino.cc>
Date: Mon, 22 Oct 2018 12:38:50 +0200
Subject: [PATCH] Check if libgtk-x11 is installed before using GTK LaF

Fixes #8119
---
 build/linux/dist/arduino | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/build/linux/dist/arduino b/build/linux/dist/arduino
index ad97c916022..9722ad03a34 100755
--- a/build/linux/dist/arduino
+++ b/build/linux/dist/arduino
@@ -24,6 +24,12 @@ if [ -x "$APPDIR/java/bin/java" ]; then
   JAVA=$APPDIR/java/bin/java
 fi
 
+GTK_LAF="-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"
+if [ `ldconfig -p | grep libgtk-x11 | wc -l` -eq "0" ]; then
+GTK_LAF=""
+echo "Falling back to Java LookAndFeel, install libgtk2.0 to restore native"
+fi
+
 # Collect options to java in an array, to properly handle whitespace in options
 JAVA_OPTIONS=("-DAPP_DIR=$APPDIR" "-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel")