LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Running GUI Program in Terminal (https://www.linuxquestions.org/questions/linux-newbie-8/running-gui-program-in-terminal-4175481915/)

mahan77 10-23-2013 05:47 PM

Running GUI Program in Terminal
 
Hello,

I need help please?
I need to run a GUI program in centos 6.4 terminal. It’s written in QT4. I have installed all the qt4 libraries. When I run the program I’m getting this error
App: cannot connect to X server. How do I solve this?
Many thanks
Sathees

smallpond 10-23-2013 07:09 PM

What desktop are you running?

andrewthomas 10-23-2013 07:29 PM

That's the problem. He has no x. No desktop.

jefro 10-23-2013 07:58 PM

I have a dumb question. Can a QT4 app run a gui from command line unless there is a X server or some other window manager running?

PTrenholme 10-23-2013 08:49 PM

Quote:

Originally Posted by mahan77 (Post 5051170)
[...]
App: cannot connect to X server. How do I solve this?
[...]

First, have you tried the obvious solution: start the X-server on you terminal.:scratch:

Now, if, instead, you meant to ask "How can I run a program that requires a running X-server without a running X-server?" Well, then, I think that the answer should be fairly clear. ;)

There are X-server emulators that can run on "pure" terminals, but I don't think that any of them support QT applications. (I haven't researched that point.)

jamison20000e 10-23-2013 08:56 PM

basically the X-server runs GUI so:
Code:

startx

bigrigdriver 10-23-2013 09:26 PM

If you are running a graphical desktop and you are getting that error, it may be that the application is not authenticated to the satisfaction of the xserver.

As user, in a terminal, issue the command: xhost +localhost. Then try to run the application.

Read up on the use of xauth and xhost for more information.

jefro 10-24-2013 05:52 PM

See a different post on this today. xinit is what you might use.

mahan77 10-25-2013 07:09 PM

Thanks for all replays.

When I try startx command its opening desktop.
What I’m looking for is, I’m trying to build POS (touch screen till) system for my friend. When user turn the till on its have to open POS software automatic in other word the desktop screen have to blank no menus or the panel.

I have to manage to auto start the POS program.

Any advice and guidance will be grade full.

Also can you advice me the best Linux distros for 1GHZ processor?

Many thanks
Sathees

jmc1987 10-25-2013 07:58 PM

Quote:

Originally Posted by mahan77 (Post 5052459)
Thanks for all replays.

When I try startx command its opening desktop.
What I’m looking for is, I’m trying to build POS (touch screen till) system for my friend. When user turn the till on its have to open POS software automatic in other word the desktop screen have to blank no menus or the panel.

I have to manage to auto start the POS program.

Any advice and guidance will be grade full.

Also can you advice me the best Linux distros for 1GHZ processor?

Many thanks
Sathees

I'm sorry I still really don't understand your question as well, but you need to have a X Server always running as it sounds. Xorg is the popular one but there are some light X Servers they may work for you.

As for a Distro that runs on a low end system. Debian, Slackware run on low end system with no problem. Both are for more advanced users, but slackware requires deeper depth in knowledge than Debian.

I run Debian on a P3 128MB Ram as a File server and it works out great.

PTrenholme 10-26-2013 12:17 AM

Have you looked at the manual pages? :scratch: man startx, man Xorg, and man Xinit all discuss methods for having a system boot the X-server and then start a specific program. Usually the "specific program" is a desktop management system, but that's not necessary.

You might also want to look at the Xclients files on you system.

Here's a Fedora default "general purpose" one, as an example of how it's done:
Code:

$ cat /etc/X11/xinit/Xclients
#!/bin/bash
# Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
# copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the
# GNU General Public License version 2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

GSESSION="$(type -p gnome-session)"
STARTKDE="$(type -p startkde)"

# check to see if the user has a preferred desktop
PREFERRED=
if [ -f /etc/sysconfig/desktop ]; then
    . /etc/sysconfig/desktop
    if [ "$DESKTOP" = "GNOME" ]; then
        PREFERRED="$GSESSION"
    elif [ "$DESKTOP" = "KDE" ]; then
        PREFERRED="$STARTKDE"
    fi
fi

if [ -n "$PREFERRED" ]; then
    exec "$PREFERRED"
fi

# now if we can reach here, either no desktop file was present,
# or the desktop requested is not installed.

if [ -n "$GSESSION" ]; then
    # by default, we run GNOME.
    exec "$GSESSION"
elif [ -n "$STARTKDE" ]; then
    # if GNOME isn't installed, try KDE.
    exec "$STARTKDE"
fi

# We should also support /etc/X11/xinit/Xclients.d scripts
XCLIENTS_D=/etc/X11/xinit/Xclients.d
if [ "$#" -eq 1 ] && [ -x "$XCLIENTS_D/Xclients.$1.sh" ]; then
    exec -l $SHELL -c "$SSH_AGENT $XCLIENTS_D/Xclients.$1.sh"
fi

# Failsafe.

# these files are left sitting around by TheNextLevel.
rm -f $HOME/Xrootenv.0

# Argh! Nothing good is installed. Fall back to twm
{
    # gosh, neither fvwm95 nor fvwm2 is available;
    # fall back to failsafe settings
    [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45'

    if [ -x /usr/bin/xclock ] ; then
        /usr/bin/xclock -geometry 100x100-5+5 &
    fi
    if [ -x /usr/bin/xterm ] ; then
        /usr/bin/xterm -geometry 80x50-50+150 &
    fi
    if [ -x /usr/bin/firefox -a -f /usr/share/doc/HTML/index.html ]; then
        /usr/bin/firefox /usr/share/doc/HTML/index.html &
    fi
    if [ -x /usr/bin/twm ] ; then
        exec /usr/bin/twm
    fi
}

Notes:
  1. The stuff after the "Argh! Nothing good is installed." comment is what happens if you boot with no window manager defined. The twm ("Tab Window Manager") is a very light-weight window manager, available on almost every distribution.
  2. The above file is actually obsolete, since current Fedora system use systemd to start the X-server and the window manager.
  3. Note, however, the sequence of program start ups. The default applications are started (if they exist) as detached processes, and then script is suspended and control passed to the window manager (the exec command) so it can "handle" resizing, etc.
  4. It's possible that all you'll need is an xinitrc that does an exec <POS_program_name>.

mahan77 10-26-2013 02:40 AM

Sorry jam1987

Lets keep it simple

I wrote a program call Hello World in GUI. When I turn on my computer running centos 6.4 I want to see Hello World program open it self. I don’t want see any of the OS menus or any think in the desktop other than Hello World app open.

Many thanks
Sathees

TobiSGD 10-26-2013 09:00 AM

At first, X and a desktop environmenment or window manager are not the same. You can run an X server without running a DE/WM and it seems that this is exactly what you want to do.
This is as easy as putting a file named .xinitrc in the home directory of your user with this line in it:
Code:

exec /path/to/your/program

mahan77 10-27-2013 02:45 PM

Hello Friends,

I have managed to do it.
* I install minimum desktop
* Install qt4 libraries (because the program written in QT4)
* Disable auto login in to Desktop (edit /etc/inittab)
* Then auto start up program via /etc/rc.local


That’s it
If any body need more information
I’m happy to help because I’m leaner to
Many thanks
Sathees


All times are GMT -5. The time now is 12:06 PM.