Graphical Application without desktop environment
Hello,
i want to start a gambas3 graphical application immediately after boot
without starting the desktop environment.
Is this possible and how to do it ?
thx wally
i want to start a gambas3 graphical application immediately after boot
without starting the desktop environment.
Is this possible and how to do it ?
thx wally
- DaveDriesen
- Posts: 113
- Joined: Sun Mar 31, 2013 8:28 pm
- Location: Top of the food chain
Re: Graphical Application without desktop environment
Hi,
There's several ways to go about this, and the best solution depends on your desires or vision.
Have a look at this simplified 3-step method, for auto-booting into anything you want (mediaplayer, game emulator, ...)
- add startx to rc.local using a specific user
- allow that user to start an X session
- configure the user's X init script to launch the app
Step 1: add startx to /etc/rc.local
The easiest cheat to start an application after the linux boot process, is to modify /etc/rc.local. This file is executed as the last step in the init process and you can use it to put all kinds of geeky stuff in there. If you're looking for something more advanced then you can create a script and add it to /etc/init.d, but let's keep things simple. The rc.local file is more than enough for day-to-day needs.
Of course, we'll be wanting to launch the X server. Hence we'll add the startx command to /etc/rc.local.As a step-by-step clarification, this will:
- impersonate a user of your choice (here it is your_user)
- start a shell of your choice (here it is /bin/bash)
- and launch startx within that shell
Step 2: allow non-interactive processes to launch an X server
Your linux distro is likely to come configured so that only root or interactive sessions (consoles or shells) can launch the X server. Non-interactive processes, such as the boot process, are typically prohibited from doing so. Seeing as you want everything to launch automatically at boot, you will need a way around this, or your X session will refuse to start at boot and all you'll see is a bunch of "permission denied" messages on your console instead.
In raspbian, reconfiguring xorg so that any user can launch xorg is done as follows:
Alternatively, edit /etc/X11/Xwrapper.config and change allowed_users=console to allowed_users=anybody.
Step 3: add your application to ~/.xinitrc
Last but not least, you need to add an entry for your gambas3 application to the specified user's xinitrc so that this applications gets started when x comes up:Note that this setup will launch one X session at boot time, and launch your application only once within that session. When the application exits, so will X, and you will be returned to the console. But you get the idea.
If you do need your x session or app to respawn then you'll be better off editing inittab, changing default runlevel, or whatnot.
I have tried to describe a very basic way of having X launch automatically during system startup, and having an application launch within that X session.
Let us know how this works out for you -- thanks!
Dave Driesen
Linux dev and oldskool elite.
There's several ways to go about this, and the best solution depends on your desires or vision.
Have a look at this simplified 3-step method, for auto-booting into anything you want (mediaplayer, game emulator, ...)
- add startx to rc.local using a specific user
- allow that user to start an X session
- configure the user's X init script to launch the app
Step 1: add startx to /etc/rc.local
The easiest cheat to start an application after the linux boot process, is to modify /etc/rc.local. This file is executed as the last step in the init process and you can use it to put all kinds of geeky stuff in there. If you're looking for something more advanced then you can create a script and add it to /etc/init.d, but let's keep things simple. The rc.local file is more than enough for day-to-day needs.
Of course, we'll be wanting to launch the X server. Hence we'll add the startx command to /etc/rc.local.
Code: Select all
#/etc/rc.local
su -s /bin/bash -c startx your_user&
- impersonate a user of your choice (here it is your_user)
- start a shell of your choice (here it is /bin/bash)
- and launch startx within that shell
Step 2: allow non-interactive processes to launch an X server
Your linux distro is likely to come configured so that only root or interactive sessions (consoles or shells) can launch the X server. Non-interactive processes, such as the boot process, are typically prohibited from doing so. Seeing as you want everything to launch automatically at boot, you will need a way around this, or your X session will refuse to start at boot and all you'll see is a bunch of "permission denied" messages on your console instead.
In raspbian, reconfiguring xorg so that any user can launch xorg is done as follows:
Code: Select all
dpkg-reconfigure x11-common
Step 3: add your application to ~/.xinitrc
Last but not least, you need to add an entry for your gambas3 application to the specified user's xinitrc so that this applications gets started when x comes up:
Code: Select all
#~your_user/.xinitrc
/usr/bin/gambas3
If you do need your x session or app to respawn then you'll be better off editing inittab, changing default runlevel, or whatnot.
I have tried to describe a very basic way of having X launch automatically during system startup, and having an application launch within that X session.
Let us know how this works out for you -- thanks!
Dave Driesen
Linux dev and oldskool elite.
-
- Posts: 118
- Joined: Wed Jan 09, 2013 12:14 pm
Re: Graphical Application without desktop environment
worked for me.....
....many thanks
....many thanks
-
- Posts: 4
- Joined: Wed Jun 26, 2013 7:44 pm
Re: Graphical Application without desktop environment
Awesome!
This worked for me with a JAVA Swing application on Raspberry PI.
On step 3, I had to change the permissions to my file ~/.xinitrc by using: sudo chmod 755 ~/.xinitrc
Thank you very much,
Sergio Soares (Brazil)
This worked for me with a JAVA Swing application on Raspberry PI.
On step 3, I had to change the permissions to my file ~/.xinitrc by using: sudo chmod 755 ~/.xinitrc
Thank you very much,
Sergio Soares (Brazil)
Re: Graphical Application without desktop environment
Works like a charm in Ubuntu 13.04 with java swing application. Thanks
!
I do have an extra question:
Can i add to the same x session a remote desktop app such as tightvnc? The idea behind it was to have remote control capabilities for the purpose of technical support to the application.
Thanks in advance to anyone that can help.

I do have an extra question:
Can i add to the same x session a remote desktop app such as tightvnc? The idea behind it was to have remote control capabilities for the purpose of technical support to the application.
Thanks in advance to anyone that can help.
Re: Graphical Application without desktop environment
Yes, have a look at x11vnc.cjnslm wrote: Can i add to the same x session a remote desktop app such as tightvnc?
Re: Graphical Application without desktop environment
Thanks for the quick response Andy.
I'm checking out x11vnc but it seems it needs a specific display to attach to and the method described in this post does not initialize any display (checked it with root@localhost> w).
I'm doing further digging for a solution on how to attach vnc server to the x display on which i'm running my java app and if i find a solution i'll be sure to post it back to this thread.
Any help is welcome though
.
I'm checking out x11vnc but it seems it needs a specific display to attach to and the method described in this post does not initialize any display (checked it with root@localhost> w).
I'm doing further digging for a solution on how to attach vnc server to the x display on which i'm running my java app and if i find a solution i'll be sure to post it back to this thread.
Any help is welcome though

Re: Graphical Application without desktop environment
It seems that whenever i start the application with startx the default display setting is ignored. If i do call startx without .xinitrc, a xterm is initialized and a display is set (as can be seen w output bellow)
Help? 
Code: Select all
13:02:39 up 43 min, 4 users, load average: 0,06, 0,10, 0,13
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty2 12:59 2:47 0.54s 0.00s xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0
pos tty1 12:53 8:39 0.79s 0.24s -bash
root pts/0 192.168.1.73 12:24 7.00s 0.69s 0.01s w
root pts/1 :0 12:59 23.00s 0.35s 0.30s -su

Re: Graphical Application without desktop environment
Finally got it
.
The problem was that the application was being ran by a normal user and i was trying to "attach" a vnc software to that session with the user root.
Once i tried to call x11vnc as the user that runs the java application i got vnc access with no problem.
Hope this helps anyone that has to find a solution to a problem similar to mine.
Thanks for the help Andy, x11vnc is great!

The problem was that the application was being ran by a normal user and i was trying to "attach" a vnc software to that session with the user root.
Once i tried to call x11vnc as the user that runs the java application i got vnc access with no problem.
Hope this helps anyone that has to find a solution to a problem similar to mine.
Thanks for the help Andy, x11vnc is great!
Re: Graphical Application without desktop environment

I get this always, i'm trying to run PureData Extended, but no results
What does it mean?
Thanks
Re: Graphical Application without desktop environment
Use approach 3 posted by Dave Driesen above.
ghans
ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
-
- Posts: 4
- Joined: Sun Mar 15, 2015 12:19 pm
Re: Graphical Application without desktop environment
I don't understand what i need to do in step 3? :/ can someone clarify please?
One more thing, i run my app like this: sudo java -jar AppName.jar
will it work this way?
One more thing, i run my app like this: sudo java -jar AppName.jar
will it work this way?
Re: Graphical Application without desktop environment
If you can run that from shell without entering password it will probably also run from script.
So if you are "pi" user, then according to the description above you do "nano ~/.xinitrc" and enter your command in that file.
I would recommend that this is done in a system that does not automatically start the desktop. Then you can test that it works with "startx" before enabling "boot to desktop".
So if you are "pi" user, then according to the description above you do "nano ~/.xinitrc" and enter your command in that file.
I would recommend that this is done in a system that does not automatically start the desktop. Then you can test that it works with "startx" before enabling "boot to desktop".
-
- Posts: 4
- Joined: Sun Mar 15, 2015 12:19 pm
Re: Graphical Application without desktop environment
oh, i got it to work, thank you for reply
i was confused with that xinitrc file
now one more question, how do i kill the app that started and get back to gui/console?

now one more question, how do i kill the app that started and get back to gui/console?
Re: Graphical Application without desktop environment
Click on the "close" button ?
Choose "file->quit" in the menu ?
Press escape ?
Its your Java application, how should we know
Choose "file->quit" in the menu ?
Press escape ?
Its your Java application, how should we know

-
- Posts: 4
- Joined: Sun Mar 15, 2015 12:19 pm
Re: Graphical Application without desktop environment
it's just a dummy window but lets not get off topic, ill get it somehow
tyvm anyway

Re: Graphical Application without desktop environment
I can get my graphical application to launch but I don't have a mouse cursor. I'm using a Logitech wireless keyboard that has an integrated track-pad. The mouse input (button press) works and the UI changes when I move the mouse around but I don't see the mouse cursor.
I've tried a simple gtk application and a xwWidgets application and get the same result.
Any thoughts?
I've tried a simple gtk application and a xwWidgets application and get the same result.
Any thoughts?
Re: Graphical Application without desktop environment
I have the same problem. I run a python script on a raspberry pi raspbian jessie distribution. The window is displayed but with no mouse cursor and no title. Can you help?mflach wrote:I can get my graphical application to launch but I don't have a mouse cursor.
Thanks
Re: Graphical Application without desktop environment
Hi Dave, I tried your approach to run a python script that uses pyQT5 extensively. Every time I reboot, the GUI application runs at tty2 instead of tty1, and I have to manually switch over to tty2 to see it. Any idea what causes it? Thanks in advance!
Re: Graphical Application without desktop environment
Dave,
Can you explain the & sign in
su -s /bin/bash -c startx your_user&
Can you explain the & sign in
su -s /bin/bash -c startx your_user&
Re: Graphical Application without desktop environment
The & sign means that the command will be spanwed of in the background so the script continues.
Re: Graphical Application without desktop environment
HI, i`m looking for a solution to run mi JAVA program at startup and I was very glad to find this thread with all the good comments.
i´m doing the procedure as described but at the moment to execute
i got an error
:
hope you could help me guys
i´m doing the procedure as described but at the moment to execute
Code: Select all
dpkg-reconfigure x11-common

how could be fixed?update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
hope you could help me guys

Re: Graphical Application without desktop environment
Sadly I could not open the GUI with the instructions on this post, so at the end I wanted to autostart my java GUI with raspbian after googled a lot and watch on youtube several videos, I took the procedure on this post :
viewtopic.php?f=91&t=65607,
During the thread several guys give enough info to get the autostart gui attached to a lxterminal. For now it just worked for me.
viewtopic.php?f=91&t=65607,
During the thread several guys give enough info to get the autostart gui attached to a lxterminal. For now it just worked for me.

Re: Graphical Application without desktop environment
after a few houres of research and debugging i found a way to make daves process working
the problem seems to be that x server has been updated in some from that disables some of the commands and reinstalling a legacy version of it seems to fix this
the problem is that in step 2 you will and an error when running this command
saying
to fix this there a 2 steps
step 1
follow instructions on this link
http://www.websences.com/dpkg-reconfigure-x11-common/
step 2
edit
your file will look something like this
put a # in front off the line containing
after that put
replace youre_user with
and replace
the problem seems to be that x server has been updated in some from that disables some of the commands and reinstalling a legacy version of it seems to fix this
the problem is that in step 2 you will and an error when running this command
Code: Select all
dpkg-reconfigure x11-common
Code: Select all
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
step 1
follow instructions on this link
http://www.websences.com/dpkg-reconfigure-x11-common/
Code: Select all
dpkg-reconfigure x11-common
Posted on April 19, 2017
After X server update 1.18.4 `su — pi -c “startx” &` not working anymore
Jessie updated xserver-xorg-core to 1.18.4 from 1.17.2, to fix the problem
sudo dpkg-reconfigure x11-common
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
sudo apt-get install xserver-xorg-legacy -y
sudo nano /etc/X11/Xwrapper.config
#Change console to anybody
allowed_users=anybody
edit
Code: Select all
sudo nano /etc/X11/xinit/xinitrc
your file will look something like this
Code: Select all
#!/bin/sh
# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)
# invoke global X session script
. /etc/X11/Xsession
as this will launch the default user interface. /etc/X11/Xsession
after that put
Code: Select all
#~your_user/.xinitrc
/usr/bin/gambas3
ore any othere userpi
and replace
with what ever youre command is fore java it can be/usr/bin/gambas3
Code: Select all
sudo java -jar path to youre -jar file and launch options