Score:1

How to launch application on startup

cn flag

I'm pretty new to Ubuntu and recently ran into an interesting issue. I installed Keep Presence (https://github.com/carrot69/keep-presence) to prevent my Intel Compute Stick from idling. What I would like to do is have this launch when Ubuntu starts. I looked around and saw you could add your commands to rc.local, so I ran sudo nano /etc/rc.local and added keep-presence --seconds 30 to rc.local, but I don't think that did anything. After saving, I re-opened to confirm the line I added was still there, just in case I did that wrong. Is there a way to tell if it's working or am I doing this completely wrong? When I restart, everything starts up like normal, so I'm not seeing an error or anything. But a terminal window doesn't open or anything like that, which would give me peace of mind knowing it's working. My version is Ubuntu 20.04.3 LTS Any ideas?

Thanks,
Josh

Score:1
cn flag
raj

First: in new Ubuntu versions, the file /etc/rc.local does not work anymore. If you want to run something at system startup, you should add it to the crontab (see man 5 crontab) using @reboot time specification.

Second: you cannot run a command that interacts with the desktop that way, because of two reasons: a) when the system starts, your GUI desktop is not ready yet, so there's simply no place where the application window could be displayed; b) a command that runs from crontab (or /etc/rc.local, if it would work) does not share the environment with your desktop session, so is missing important system variables required for GUI applications to work.

The solution is to add your application to "Startup Applications" in your desktop session (there's a special tool for that) - then your application will start together with your desktop session when you log in.

Score:1
cn flag

You should not start up an application that regularly simulates a mouse click, such as this "keep-presence" utility, using system wide installation procedures. Instead, you should enable automatic startup of these applications when the user logs in. Anyway, the program will probably fail if you decide to attempt otherwise, because it needs a graphical environment to run.

The easiest way to have an application autostart is to launch the tool "Startup applications". In the dialog, click Add and fill the fields.

That has to be done for each user account. If you rather want this to happen by default for each user account on the system, then a .desktop launcher for this command can be moved to /etc/xdg/autostart.

The easiest way to create such .desktop launcher is actually to use "Startup applications". That will create such .desktop launcher in the user's local autostart folder, i.e., ~/.config/autostart. Move that to the systemwide /etc/xdg/autostart to have it in effect for all users.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.