Starting a GUI app on startup with a RaspberryPi

I got a new Raspberry PI4 and I set it up to record some over the air TV and the app I was using allowed to set a schedule much like old school VHS recorders would. BUT you have to have the application running all the time so if you forget to start it the recording is missed. Most all the search results for Raspbery Pi or Linux about autostart a program just would not work.

Finally I found somebody who said if it had a GUI it would not load under traditional methods since the came into play before the Graphical Interface. Anyway I was having no luck. And finally under some lucky combination of search words I found this site.


Here is the gist with a few changes for my situation

You only need to do this part once, but you need to do it first. Click on Applications -> Preferences -> Main Menu Editor on your Pi desktop.

In the Main Menu Editor window click on Preferences in the first column. Check the box for Default applications for LXSession in the second column. Click Okay.
Now when you click on your Applications -> Preferences menu you should see Default applications for LXSession listed. You don't need to click on it yet, but you'll need it after the next step.

Find out the command to start the GUI program which for me was the path to the program and supposedly by adding -m afterwards would start it minimized (it didn't). But anyway /usr/bin/Kaffeine -m

Now that you have the command syntax you need to add it to the autostart sequence. Choose Applications -> Preferences -> Default applications for LXSession from your Pi desktop. Select the Autostart tab.
In the Manual autostarted applications section enter the text of your command in the box next to the Add button. Then click the Add button and your new command should be added to the list. When your Pi boots (or reboots) these commands should run.
You can temporarily disable a command by unchecking the box in front of it. This will add # in front of the command and it will be ignored until you go back and check it. And obviously you can remove a command from the sequence completely by clicking the Remove button beside it. (There is no undo for this)

No comments: