Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected appearance of Arduino IDE using CLI #1970

Open
hanabanana opened this issue Mar 28, 2014 · 24 comments · May be fixed by #9295
Open

Unexpected appearance of Arduino IDE using CLI #1970

hanabanana opened this issue Mar 28, 2014 · 24 comments · May be fixed by #9295
Labels
Component: CLI The Arduino IDE's command line interface Help wanted Arduino would especially appreciate assistance from the community on this item OS: OSX Specific to the Mac OS X (macOS) version of the Arduino IDE Type: Bug

Comments

@hanabanana
Copy link

I tried using the official CLI of arduino 1.5.5-r2. It worked except that it opened up the Arduino IDE window after issuing the command, compiled and downloaded the sketch, then autoclosed itself. This is not consistent with what has been described in the documents. Is this a known bug? If so, is there a workaround like setting a hidden flag or something?

Thanks for any help.

@matthijskooijman
Copy link
Collaborator

This was fixed in 1.5.6 already.

@hanabanana
Copy link
Author

Thanks, Matthijs. I tried it out and it no longer shows the content of the IDE but just the Arduino logo. Is there a way to make everything completely hidden as in not show anything?

@matthijskooijman
Copy link
Collaborator

Oh, the splash screen of course. I've been developing this on Linux, which I think doesn't show the splash screen (or perhaps it's only used in release builds, dunno). Perhaps there is a (hidden) preference to disable the splash screen altogether, though I do not think there is a comprehensive list of them anywhere.

In any case, I'll see if I can fix this in the code for the next release. Thanks for reporting.

@matthijskooijman
Copy link
Collaborator

@matthijskooijman

@matthijskooijman
Copy link
Collaborator

Hmm, looking around it seems the splash screen is shown by the launcher, not by the java application itself. I think this means we won't be able to toggle it based on a commandline option.

However, perhaps we can make an arduino.exe to run from the commandline and a arduino_gui.exe to run from e.g. the startmenu? Both binaries would be identical, except that only the latter uses the splash screen.

As a side effect, this means that if you run arduino from the commandline without --verify or --upload, the GUI will be shown without the splash screen, but I don't think that is a problem in any way.

@cmaglie, how does that sound? Are there other options?

@ffissore
Copy link
Contributor

Sorry for the late reply.
Since release 1.5.7, the Windows version has two ways for starting the IDE: arduino.exe will show the splash screen, arduino_debug.exe will not and will echo to the terminal whatever gets printed on the black lower part of the ide.

@Lauszus
Copy link
Contributor

Lauszus commented Apr 9, 2015

This is still a issue on Mac OS X. I got it working by removing: https://github.com/arduino/Arduino/blob/master/build/build.xml#L321, but of course that is not a usable fix.

@ffissore
Copy link
Contributor

ffissore commented Apr 9, 2015

Yep. Problem is that splash screen is a command line arg. On Linux we have a bash script, so we may make args dynamic. On win and mac they are not. On win you can use arduino_debug (although the name looks weird) but on mac we have one binary only, so no joy

@FlsZen
Copy link

FlsZen commented Apr 17, 2015

In addition to Lauszus' suggestion, I also wanted the dock icon to not show so I added "-Dapple.awt.UIElement=true" into Info.plist.

@ffissore ffissore added the OS: OSX Specific to the Mac OS X (macOS) version of the Arduino IDE label Apr 22, 2015
@ffissore
Copy link
Contributor

I've googled around once more and I'm sorry to say this kind of macosx issues are a "wontfix". Tagging them as such and leaving them open until something better than a hack is found

@ffissore ffissore added the Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature label Apr 30, 2015
@ffissore ffissore added the Help wanted Arduino would especially appreciate assistance from the community on this item label Jun 19, 2015
@ffissore ffissore self-assigned this Jul 1, 2015
@ffissore
Copy link
Contributor

You may want to try our new shiny arduino-builder: it only compiles (so it's not a complete replacement) but it's a pure CLI tool

@igorwwwwwwwwwwwwwwwwwwww

I managed to find a way to run this on OSX. I created this file as arduino.sh:

#!/bin/bash

APP_ROOT=/Applications/Arduino.app
JVM_RUNTIME=$(/usr/libexec/java_home)

java \
    -cp "$APP_ROOT/Contents/Java/*" \
    -DAPP_DIR=$APP_ROOT/Contents/Java \
    -Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:$JVM_RUNTIME/Contents/Home/jre/lib/ext/ \
    -Dfile.encoding=UTF-8 \
    -Dapple.awt.UIElement=true \
    -Xms128M \
    -Xmx512M \
    processing.app.Base \
    "$@"

Now I can run it from the cli as:

$ ./arduino.sh --verify ~/Documents/Arduino/my_project/my_sketch.ino

It doesn't show the splash screen, and it doesn't show up in the dock.

Enjoy!

@facchinm
Copy link
Member

Should be fixed since 1.6.13 after merging #5578 and #5131. @igorwwwwwwwwwwwwwwwwwwww , which version are you using? Are you trying to solve the "appear on dock" issue or the unexpected graphics?

@facchinm facchinm added the Waiting for feedback More information must be provided before we can proceed label Aug 14, 2017
@igorwwwwwwwwwwwwwwwwwwww

@facchinm I was trying to solve both, on osx specifically.

@Aerijo
Copy link

Aerijo commented Sep 5, 2017

@facchinm I have this probelm using version 1.8.3 on Mac. Running arduino --verify or similar will cause the 'splash screen' to appear in the foreground, and a black 'exec' dock icon will also appear.

Both still happen if the application already open. Neither happen when clicking the compile command in the application menu.

@facchinm
Copy link
Member

facchinm commented Sep 5, 2017

I get it. We should set apple.awt.UIElement=true using System.setProperty() on OSX only if CLI parameters are provided. This should be quite easy, I'll try to code something 🙂

@facchinm
Copy link
Member

facchinm commented Sep 5, 2017

Looks more difficult than I thought... The patch should be

diff --git a/app/src/cc/arduino/view/SplashScreenHelper.java b/app/src/cc/arduino/view/SplashScreenHelper.java
index 108c1c8b2..69d617e8c 100644
--- a/app/src/cc/arduino/view/SplashScreenHelper.java
+++ b/app/src/cc/arduino/view/SplashScreenHelper.java
@@ -36,6 +36,7 @@ import java.awt.geom.Rectangle2D;
 import java.util.Map;
 
 import processing.app.Theme;
+import processing.app.helpers.OSUtils;
 
 public class SplashScreenHelper {
 
diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java
index 9a91d68dd..db41e335e 100644
--- a/app/src/processing/app/Base.java
+++ b/app/src/processing/app/Base.java
@@ -132,10 +132,6 @@ public class Base {
     }
     System.setProperty("java.net.useSystemProxies", "true");
 
-    if (OSUtils.isMacOS()) {
-      ThinkDifferent.init();
-    }
-
     try {
       INSTANCE = new Base(args);
     } catch (Throwable e) {
@@ -225,6 +221,9 @@ public class Base {
       // Use native popups so they don't look so crappy on osx
       JPopupMenu.setDefaultLightWeightPopupEnabled(false);
     } else {
+      if (OSUtils.isMacOS()) {
+        System.setProperty("apple.awt.UIElement", "true");
+      }
       splash = new SplashScreenHelper(null);
     }

but it doesn't have any effect... Probably it's due to something like the issue reported here.
If anyone can spot the problem with this approach I'll be glad to try another fix 😉

@per1234 per1234 removed Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature Waiting for feedback More information must be provided before we can proceed labels Sep 5, 2017
@martistra
Copy link

An easy hack to get out of the splash screen altogether on a Mac is to rename the splash.png to ihatethissplashscreen.png. Found in /Applications/Arduino.app/Contents/Java/lib/splash.png

@asm13243546
Copy link

asm13243546 commented Apr 7, 2018

Hey .. is there dedicated or otherwise comprehensive documentation for arduino-builder? I'm on Arch. I get lots of CTAGS missing errors in my verbose output.

@ianfixes
Copy link

A while ago I had used @igorwwwwwwwwwwwwwwwwwwww 's comment to disable the splash screen.

#!/bin/bash

APP_ROOT=/Applications/Arduino.app
JVM_RUNTIME=$(/usr/libexec/java_home)

java \
    -cp "$APP_ROOT/Contents/Java/*" \
    -DAPP_DIR=$APP_ROOT/Contents/Java \
    -Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:$JVM_RUNTIME/Contents/Home/jre/lib/ext/ \
    -Dfile.encoding=UTF-8 \
    -Dapple.awt.UIElement=true \
    -Xms128M \
    -Xmx512M \
    processing.app.Base \
    "$@"

Using Arduino 1.8.7 on OSX 10.13.6 (17G65), this no longer works.

Error: Could not find or load main class .Applications.Arduino.app.Contents.Java.arduino-builder
Caused by: java.lang.ClassNotFoundException: /Applications/Arduino/app/Contents/Java/arduino-builder

What's the new "preferred" way to do this? I had previously looked at arduino-builder, but I have some cross-platform scripting functionality that currently uses the command-line option syntax for the GUI executable. Should I be making plans to switch over to something else?

andrewdotn added a commit to andrewdotn/Arduino that referenced this issue Oct 7, 2019
Fixes arduino#1970

On macOS, when running,

    Arduino.app/Contents/MacOS/Arduino --upload sketch.ino

a splash screen is visible the entire time the upload is running.

This PR hides that splash screen as soon as it’s known for sure that the
GUI should not be displayed. This makes for a slightly better user
experience: there’s still a splash screen, but it only appears briefly at
launch time.

The [SplashScreen docs][] explain:

> The splash screen can be displayed at application startup, before the
> Java Virtual Machine (JVM) starts. ... is closed automatically as soon as
> the first window is displayed by Swing/AWT (may be also closed manually
> using the Java API, see below)

[SplashScreen docs]: https://docs.oracle.com/javase/7/docs/api/java/awt/SplashScreen.html
andrewdotn added a commit to andrewdotn/Arduino that referenced this issue Oct 7, 2019
Fixes arduino#1970

On macOS, when running,

    Arduino.app/Contents/MacOS/Arduino --upload sketch.ino

a splash screen is visible the entire time the upload is running.

This PR hides that splash screen as soon as it’s known for sure that the
GUI should not be displayed. This makes for a slightly better user
experience: there’s still a splash screen, but it only appears briefly at
launch time.

The [SplashScreen docs][] explain:

> The splash screen can be displayed at application startup, before the
> Java Virtual Machine (JVM) starts. ... is closed automatically as soon as
> the first window is displayed by Swing/AWT (may be also closed manually
> using the Java API, see below)

[SplashScreen docs]: https://docs.oracle.com/javase/7/docs/api/java/awt/SplashScreen.html
@andrewdotn andrewdotn linked a pull request Oct 7, 2019 that will close this issue
7 tasks
@pchar
Copy link

pchar commented Feb 17, 2020

I've found a workaround for this issue on macOS :

  • Edit the plist in /Applications/Arduino.app/Contents and simply remove the xml tag <splash-scren ..>
  • to avoid that is you are in full screen the Arduino app get the main focus you must create a simple script (in Contents/MacOS) like run-arduino.sh that contains the following line "open -g ./Arduino"

@itopaloglu83
Copy link

I've found a workaround for this issue on macOS :

  • Edit the plist in /Applications/Arduino.app/Contents and simply remove the xml tag <splash-scren ..>
  • to avoid that is you are in full screen the Arduino app get the main focus you must create a simple script (in Contents/MacOS) like run-arduino.sh that contains the following line "open -g ./Arduino"

I must be doing something wrong. When I make the changes above instead of the splash screen I'm getting the output directory opening up with finder.

~/.vscode/extensions/vsciot-vscode.vscode-arduino-0.3.4/out/src/arduino

@Phinder
Copy link

Phinder commented Apr 13, 2021

I managed to find a way to run this on OSX. I created this file as arduino.sh:

#!/bin/bash

APP_ROOT=/Applications/Arduino.app
JVM_RUNTIME=$(/usr/libexec/java_home)

java \
    -cp "$APP_ROOT/Contents/Java/*" \
    -DAPP_DIR=$APP_ROOT/Contents/Java \
    -Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:$JVM_RUNTIME/Contents/Home/jre/lib/ext/ \
    -Dfile.encoding=UTF-8 \
    -Dapple.awt.UIElement=true \
    -Xms128M \
    -Xmx512M \
    processing.app.Base \
    "$@"

Now I can run it from the cli as:

$ ./arduino.sh --verify ~/Documents/Arduino/my_project/my_sketch.ino

It doesn't show the splash screen, and it doesn't show up in the dock.

Enjoy!

And if You are "new to programming" like me and can't nail the above, there is a barbarous way... Simply rename or delete the "splash.bmp" and "splash.png" files at /Applications/Arduino.app/Contents/Java/lib/
however, it gets rid of the splash screen forever.

Cheers

@ianfixes
Copy link

If folks aren't aware:

you can avoid the IDE completely with the relatively-new CLI utility: https://github.com/arduino/arduino-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CLI The Arduino IDE's command line interface Help wanted Arduino would especially appreciate assistance from the community on this item OS: OSX Specific to the Mac OS X (macOS) version of the Arduino IDE Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.