I'm trying to get a Qt application to launch immediately after booting up. When booted, the Linux image does nothing more than launch an X server and a terminal. It also has the cron daemon running in the background. Obviously, my Qt application needs the X server to be running to do anything.
I've seen a similar question for Red Hat and SUSE Linux.
However, I don't see this working for my image.
I'm wondering if there is a standard way in Linux/UNIX to make a GUI application start immediately after the X Server.
[sj755@localhost X11]$ tree /etc/X11/
/etc/X11/
|-- functions
|-- Xdefaults
|-- Xinit
|-- Xinit.d
| |-- 01xrandr
| |-- 11zaurus
| |-- 12keymap
| |-- 40xmodmap
| |-- 50setdpi
| |-- 55xScreenSaver
| |-- 60xXDefaults
| |-- 89xTs_Calibrate
| `-- 98keymap-fixup
|-- xmodmap
| |-- a716.xmodmap
| |-- collie.xmodmap
| |-- default.xmodmap
| |-- h1910.xmodmap
| |-- h2200.xmodmap
| |-- h6300.xmodmap
| |-- hx4700.xmodmap
| |-- keyboardless.xmodmap
| |-- omap5912osk.xmodmap
| |-- poodle.xmodmap
| |-- shepherd.xmodmap
| |-- simpad.xmodmap
| |-- slcXXXX.xmodmap
| |-- xmodmap-invert
| |-- xmodmap-left
| |-- xmodmap-portrait
| `-- xmodmap-right
|-- xorg.conf
|-- Xserver
|-- xserver-common
|-- Xsession
`-- Xsession.d
|-- 60xXDefaults
|-- 89xdgautostart
`-- 90xXWindowManager
3 directories, 36 files
root@devboard:~# cat /etc/X11/Xsession.d/90xXWindowManager
if [ -x $HOME/.Xsession ]; then
exec $HOME/.Xsession
elif [ -x /usr/bin/x-session-manager ]; then
exec /usr/bin/x-session-manager
else
exec /usr/bin/x-window-manager
fi
#!/bin/sh
#
# Very simple session manager for Mini X
#
# Uncomment below to enable parsing of debian menu entrys
# export MB_USE_DEB_MENUS=1
if [ -e $HOME/.mini_x/session ]
then
exec $HOME/.mini_x/session
fi
if [ -e /etc/mini_x/session ]
then
exec /etc/mini_x/session
fi
MINI_X_SESSION_DIR=/etc/mini_x/session.d
if [ -d "$MINI_X_SESSION_DIR" ]; then
# Execute session file on behalf of file owner
find $MINI_X_SESSION_DIR -type f | while read SESSIONFILE; do
set +e
USERNAME=`stat -c %U $SESSIONFILE`
# Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
# su -l -c '$SESSIONFILE&' $USERNAME
sudo -b -i -u $USERNAME $SESSIONFILE&
set -e
done
fi
# This resolution is big enough for hob2's max window size.
xrandr -s 1024x768
# Default files to run if $HOME/.mini_x/session or /etc/mini_x/session
# don't exist.
matchbox-terminal&
exec matchbox-window-manager
Best Answer
Have a look at
/etc/X11/xinit/xinitrc
(this may be different places on different systems) to see what files it sources. Generally, this will have an if..elif..else structure, so that only one initialization file is read, with$HOME/.Xclients
prioritized then/etc/X11/xinit/Xclients
. That's almost certainly where the terminal that appears comes from (I am presuming you do not have a desktop environment installed or anything).Anyway, if you just want to run a single GUI app, create (or modify) an Xclients file like this:
This should be executable. It's pretty much a normal shell script, I believe, so you can have more stuff in there, although obviously not backgrounding a GUI app will block execution at that point.
[later addition]
Your installation doesn't have exactly those files, but it does have an
/etc/X11/Xinit.d
and if you look, I am sure those are short shell scripts and they are sourced from somewhere, probably one of the files in/etc/X11
--Xsession
,Xserver
, orxserver-common
. You might want to check if$XINITRC
is defined in your environment; that will be a clue.Your best bet is probably to just create a
$HOME/.Xclients
file (or as jofel mentions,$HOME/.xinitrc
, which is probably more universal) and try it -- exactly that spelling and case, with a leading dot, and it should be setchmod 755
(the group and other permissions may not matter). Almost certainly this will be sourced from somewhere properly.You can put files in
/etc/X11/Xinit.d
yourself, but doing it for this purpose is not a good idea because yours should run last and block further execution. So have a look at the scripts in/etc/X11
(again:Xsession
, etc., they don't have a.sh
suffix) and try to figure out in what order they all chain together. It is also likely that somewhere one of them checks for anXclients
file, eg via something like$HOME
may also be used, and.xinitrc
. Which is why creating at least one of these variations should work (write the file and move around/rename it if at first you don't succeed). To summarize: prime candidates for the name:.xinitrx
and.Xclients
, in either$HOME
or/etc/X11/
, but if in the later, ditch the leading dot.