Score:0

Scheduling tasks a certain amount of time after login

ng flag

I have written a python program that reads from email. If a certain string is received from email then it does nothing. But if the python program does not receive that string, it runs a bash script, the bash scripts shuts the computer down.

I want to run this python program 2 minutes after user is logged in.

What I tried: I added a sleep timer in the python program, and added the program in '.profile' file in my home folder. But it is not very smooth to wait for 2 minutes after login for the computer to start.

So is there any way to run the python program 2 minutes after login without disrupting startup.

Score:1
cn flag

Gnome Shell and desktops derived from Gnome support X-GNOME-Autostart-Delay in the .desktop launcher of the program that is to be autostarted. These launchers are located under ~/.config/autostart (for the current user only) or /etc/xdg/autostart (for all users). Edit the launcher and add a line in the sense

X-GNOME-Autostart-Delay=120

A method working on any desktop involves the use of the sleep command, which is incorporated in the Exec= line like

Exec=sh -c "sleep 120 && myapp"
Anusheen Nema avatar
ng flag
It worked. Thanks a lot. I created a new .desktop file in /etc/xdg/autostart/. Added X-GNOME-Autostart-Delay=120 at the end.
Anusheen Nema avatar
ng flag
Can I ask you how you became such an expert. What do I have to learn to know such intricacies? (You don't have to answer sir.)
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.