1

I have a python application that logs data from connected sensors. Most of the time it just sits there logging data. If power is lost and regained, I want it to start this application automatically so I don't have to worry about restarting it if something happens. I don't really want to boot to desktop first, because most of the time, I don't care what the data looks like, I'm just logging it. But, I may want to connect a display to it and see what the data looks like every now and again.

If my raspberry pi boots to cmd line and begins this python script automatically, is there a way I can start the desktop without closing the python script? The python script also contains code that shows a User Interface on command but naturally needs the X display to show anything. I don't want to have to stop the logging behavior while I wait for the desktop to boot up. Is this even a possibility?

My ideal usage:

  1. Start logging data on boot
  2. Start GUI on keyboard command without closing logging script
  3. Exit GUI on command (keyboard or GUI controls) without closing logging script so that I'm not wasting resources if no display is required

I appreciate any and all input. Like I said, I don't even know if it's possible to do this.

1

Yes, all this is possible but the fact that the script may include a (graphical?) user interface makes it a complicated task.

I'd advise you break it down and tackle, in order:

  1. Getting the logging script to run on boot without any potential foreground UI.

  2. Get the same (background) script to respond to commands -- this means a client/server architecture, which is how most of the background things started at boot work.

  3. Get the background logging service to start a foreground GUI process (in response to a client request) which will report from the log/control the logger.

This is a fair bit of work, but it is a "want my cake, eat it too" = bake cake first scenario.

A simpler spin would be to have a background logging app start at boot, and a completely separate foreground interactive app that can read the log. However, this is no good if you need the user interface to be able to control the logger.

-3

I have done this two ways. On my server, which has a cinnamon desktop I use sudo service mdm stop/restart. You might have/use a different different desktop manager like gdm or lightdm.

Also I had done it on my Debian core install. Installed lxde-core

install the "xinit" package

echo "exec lxsession" > ~/.xinitrc

then you can start the de by typing startx

  • When connecting via ssh, you need to enable "all users can start a x-server" via dpkg-reconfigure x11-common. Otherwise it will tell you, that only users with local console can start the X-Server. – allo Jul 2 '16 at 20:31

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.