I am trying to write a unit service file for a program that has a GUI.

I have an ubuntu server from DigitalOcean and I connect to it with TightVNC to display:2.

The GUI requires a username and password to log in to my account online. While this program is open, it allows connecting to their server through port 4002 and request data online using a python script.

The program can be authenticated with a given username and password in the terminal. The following will open the program, automatically login to my account, and displays the program GUI.

$ /home/user1/ibg/ibg username=*** password=***

The unit file that I wrote is as follows:

Description=my service

ExecStart=/home/user1/ibg/ibg username=*** password=***


The service is active and running but I get the following message which I think prevents the service to be truly functional. I can tell this from the fact that my python script is not working. If instead, I open the program GUI, and log in to my account, the python program works with no issue.

No X11 display variable was set, but this program performed an operation that requires it.
at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:117)

Could someone kindly help me with this problem?


Have you tried setting the DISPLAY variable to :2 for your service's ExecStart environment?

See this serverfault question:

You have an option to use either the Environment= flag directly in the [Service] section of your unit file, or you can use the .conf file approach described in the top voted answer in that question.

  • Yes, I tried both 0 and 2 by adding Environment=Display:0 but it did not help. Still complains about No X11 DISPLAY variable was set, but this program performed an operation which requires it.. – AFPP Aug 19 '20 at 4:49
  • 1
    Environment variable names are case-sensitive. Try it with Environment="DISPLAY=:2". – Jordan Deyton Aug 19 '20 at 4:51
  • Thank you. It worked. – AFPP Aug 19 '20 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.