How to start a gtk application after booting up without logging in? - linux

I have got a gtk application. I want it to start automatically when I boot up the system, such that instead of getting usual login screen, my application greets the user.
My application is a sort of cash dispensing application. So user should not even see the login screen of linux. Whenever machine in boot up, after loading services and all that, my application should appear on the screen. One should not have to put any password or login in anyway to start that application.
Now so far I have tried the following but all in vain.
I put the command in my /etc/rc.local file
/home/EXE/cashier
Then rebooted machine in run level 5. But nothing happens. I get the usual login screen. Other programs that do not involve any gui or gtk, they are automatically started in this manner but not the gtk application.
Then I put
xint /home/EXE/cahier
and later
xint /home/EXE/./cashier
But they too didn't work. When I looked into details, I found out that "An Xserver is already running on screen 0, cannot open other server" or something like that.
Then I tried booting into run level 3, this time it worked.
xint /home/EXE/.cachier
But in run level 3, the font and icon sizes are smaller. Moreover some windows do not cover the whole screen.
Now I will really appreciate a way to run my application in run level 5, without showing login screen automatically.
Regards
Edit
Currently, the application is running on fedora core 2

This is more a question about linux distribution startup than it is about Gtk applications. The specifics are going to depend on your distribution, but the essence is:
Disable the gdm facility, which is normally responsible for spawning your X server.
Run xinit (not "xint") to start the server manually. This takes a client as its argument. It may work to run your Gtk application directly (it needs to be smart enough to position and size itself instead of relying on a window manager), but more likely you will want to pick a window manager to run it in. The easiest way to do this is via script that you pass to xinit.

Related

Making a GUI in Linux without booting the OS's GUI

Sorry if I'm using wrong terminology here.
I'd like to make an appliance for users that's running from a Raspberry Pi. When it's booted, I'd like users to see my own GUI that I'll design (hopefully in PyQT but I'm not sure about that yet.)
The thing I don't know how to do: I don't want the users to see the Linux operating system on the screen at all. I don't want them to see the desktop and launch my app. I want my app to be automatically launched on startup. I want it to be the only thing accessible and visible to the users. i.e. it should be full-screen and a user wouldn't be able to exit it or interact with the OS in any way.
How can I do that?

Does a window need a graphical environment to exist?

This one is a pretty strange question of mine so I'll try to explain the best I can.
On a DOS Linux distribution, without having installed any graphical environment, if I start an application which is supposed to have a GUI, will I be able to interact with that window via code?
What I thought is that if KDE/GNOME's role is to graphically represent an existing GUI, I should be able to interact with it but if these graphical environments have an active role in the window creation there is nothing I can do.
You won't be able to run a graphical program without a window manager.
The reason is that the window manager is doing a lot more than just allowing the window to be shown to the user. It comes with libraries and services for constructing windows and components and interacting with them. Without these libraries and services, the program won't be able to start.
The only exception would be if a program contained all the graphical code built into it, and didn't rely on a window manager. Realistically this would only happen for a fairly simple program and in special cases; for instance, Raspbian includes OMXPlayer, which shows full screen video without relying on any window manager.
Quoting (with some adaptation) from https://raspberrypi.stackexchange.com/a/3974 which answers how to start mplayer in X11 without a window manager:
The X server is really usually called X and you can just start it. You can set the DISPLAY number as an argument along with some other things.
You might want to have some sort of session, though, and still go through xinit or such and start X with startx. You can use .xinitrc or such as a script and simply not start a window manager there. You will need a "magic client" as the last command that stays running so X doesn't terminate immediately. In a traditional "failsafe" session, that was an xterm. If you know what to launch and launch once only, it could be that program or any UI/wrapper that does the launching for you. When the last ("magic") client in the init script terminates, X terminates.
If all you want to do is play video, you might see if you can run mplayer with directfb instead and skip using X11 entirely.

Hardware+OS setup for an Application

I want to make a system which would get input from USB barcode scanner, validate it on remote server and display an answer (text and images).
I would use JavaFX or in-browser JS web application to grab scanner input somehow.
I'm planning to run this application on Raspberry Pi or plain PC.
Is there a way (or a special linux distribution) to ensure that system always loads the same way and starts JavaFX app or opens particular web page in browser?
e.g. no login page, NO update or other popups are shown.
Any other ideas? Thanks
...
Found an interesting solution here, where JavaFX GUI app is started from command line, without X-Server(linux graphical interface) at all.
I have recently done something similar, and it's not too hard. Obviously working on the Pi, you will want to use something like Linux and having limited hardware will mean that you should be minimising what you are running. Due to this, I would recomend that you run a light weight distro. Something like arch (which is what I used) allows you to build only what you want from the ground up without the need to find and compile everything like you do for LFS or Gentoo.
As for booting, the following two wikis will give you the details of starting the Gui without manual login:
https://wiki.archlinux.org/index.php/Automatic_login_to_virtual_console
https://wiki.archlinux.org/index.php/Start_X_at_Login
After that, it is simply a matter of putting the command to launch your program in .xinitrc.

enable breakpoint while debugging user input (gdb/linux)

Recently I've been running into a problem where I want to enable a break-point in the middle of being in an interactive application (keyboard and mouse - dragging modal UI elements).
I want to be able to enable a break point once the application is already running and in the state I want.
The ability to ignore the breakpoint N times, can work - but dealing with mouse motion its a hassle to get right (not very predictable).
Ideally I could have a 3rd device (I joystick button of foot pedal for example), and press it when I want to enable the breakpoint.
Another option could be to SSH into my system from a second system and enable the breakpoint this way.
Is anyone aware of some good ways to interactively enable enable breakpoints while the application runs?
When debugging an interactive X11 application, running the debugger from a separate workstation was pretty much a requirement ... until introduction of Xvfb.
These (running debugger from a separate workstation or running the app in Xvfb) are pretty much your two plausible choices.

How to launch firefox from C program/daemon under Linux

I am having some problems with launching firefox from a Linux daemon written in C.
When I launch firefox on the machine itself (via terminal) from the command shell using /usr/bin/firefox it works OK and a firefox browser window lanunches as it should.
However if I try this within my C daemon using system("/usr/bin/firefox"), firefox launches its process in the terminal but the browser window is not opened?
A similar thing happens when I try to do this using remote terminal acces. It's something to do with telling the system to open firefox in window mode rather than trying to open it in terminal mode - but I dont know how to specify this using bash commands?
I am using Lubuntu 11.10 in my Linux System.
Any help is most appreciated.
There's a reason I asked why you're attempting to do what you want. I didn't want to get into great details in my comment.
Firefox on Unix is an X-Window process (most of the Linux/Unix desktops are based upon the X11 protocol which is the heart of X-Window). What X-Window does is separate the display of the program from the process running the program. For example, I am now running Firefox from a Linux box at work, but the Linux box is actually displaying the Firefox browser window at home on my Mac.
In order to do this, I had to:
Run X11 on my Mac. The X11 program creates a default X11 client display called 0.0 which pretty much says the first screen and the first instance of X11 running (computer geeks like counting from zero). The process runs in the background on my Mac. In a certain sense, it's really a server process and not a client because it's waiting on port 6000 for a client X11 process (Firefox) to tell it what to do.
Before I run firefox, I have to tell my Mac's X11 process that I grant the X11 server running Firefox to be able to display on my X11 client process. Otherwise, you can imagine someone spamming another person by continuously popping up Windows on their display. You can use the xhost program to do this.
In order to run Firefox on the Linux box, I have tell the Firefox process what X11 client I'm running it on. I can do this by setting the DISPLAY environment variable to something like "10.0.1.33:0.0". This means the X11 client is running the the machine on IP address 10.0.1.33, and I want you to use the first screen, and the first instance of the X11 client on that screen.
Now, I can run Firefox on my Linux box, and the display will display on my Mac.
The problem you're running into is that there's simply no X11 client when you're starting FireFox as a daemon process. An X11 client is associated with a user and a display of some sort. The display could be a virtual display, but there's got to be an X11 client that's running and is addressable in some way, so the process knows where to display the output.
By the way, you said daemon which has a very, very specific meaning in Unix/Linux. A daemon is a process that runs in the background and usually has a service (and a port) associated with it. For example, there's an FTP daemon called ftpd, the mail server uses the sendmail daemon, ssh has the sshd daemon. Daemons have no display associated with them.
However, it looks like you might be using the word to mean launching Firefox via another process. Is that true? If so, you'll have to make sure that Firefox knows the X11 display to use (there's a command line setting to use to specify the display), and that your X11 client (your login session) has given permission for another process to update your display with the program window.
Can you please explain what you're trying to do in a bit more detail? If you simply want to download a file from a remote http server (which of course is running the http daemon process called httpd), you should use curl or wget which don't require a display and are way simpler to use. If you're trying to do something else, let us know exactly what it is.
Firefox needs to know which display it should open on. When you run it from within a gui, even through a terminal emulator, the DISPLAY environment variable is set to the appropriate value. When you launch from the daemon, try system("/usr/bin/firefox -display=:0").
Make sure that the DISPLAY environment variable is properly set in your daemon to refer to the X server that you want your firefox to use.
If the daemon is run as a different user account than the user account that "owns" the X server that you want to use, you will also need to use xauth(1) to configure the authentication token to grant permission to use the X server.
Often times, it is far easier to use ssh -X to tunnel X and properly configure the xauth(1) tokens in one go than try to manage xauth(1) tokens yourself. Maybe adding ssh -X into your environment would be suitable, maybe not. (I've even used ssh -X root#localhost before when I needed to run an X client as root and didn't want to bother with configuring xauth(1) manually. ssh(1) is just so much easier.)

Resources