Want to add a 3 to 5 minute delay for Deluge on startup

I have Deluge set to autostart with the system, but would like to add a 3 to 5 minute delay on it. I do not want to remove it from autostartup cause there’s a good chance I’ll forget to manually start it, but I do need a delay on it because of my external drives behavior.

Hi - have you tried making the thing that autostarts a script, which then uses the sleep command to cause that delay?

Ex. perhaps something like:

#!/bin/bash
sleep 240 && programname

I’m not currently using anything like that exactly, but I recall doing something similar a couple of years ago, I think, so forgive the lapse in memory if that’s not what you’re looking for :slight_smile:

1 Like

That would give me a 4 minute delay to deluge upon reboot? If so How is it applied? I’m assuming /bin/bash refers to my Konsole shell, if so I actually use ZSH.

Yep, you could use #!/bin/zsh instead - and basically you’d just save those couple of lines as a script file (setting however many seconds you’d want, of course), then point the Autostart at that script file instead of directly at the executable file for that application.

The effect would be that the script would be “running” for however many minutes, waiting on the sleep command to finish, and then it would execute the program you want. I’ve only ever tested with delays of a few seconds, but theoretically it should work for longer ones too!

1 Like

Is it just a simple txt file or is there more to it?

Just text :slight_smile:

For example (different purpose but just to demonstrate how it works), I have an Autostart script as part of using SSH without entering the passphrase, based on the guidance here: SSH Keys and KWallet: Getting rid of SSH asking passphrase | Soumya's Web

The script itself is just a plain-text file:

$ cat ~/.local/share/sshscript/ssh-add-login.sh 
#!/bin/bash

# Waits for kwallet to start
kwallet-query -l kdewallet > /dev/null

# Checks for all the private keys under .ssh folder
for KEY in $(ls ${HOME}/.ssh/id_* | grep -v \.pub); do
  ssh-add -q ${KEY} </dev/null
done

I used the Autostart interface in System Settings to add a new “Login Script” and pointed to that file, which then created this .desktop file:

$ cat ~/.config/autostart/ssh-add-login.sh.desktop 
[Desktop Entry]
Exec=/home/johnkizer/.local/share/sshscript/ssh-add-login.sh
Icon=application-x-shellscript
Name=ssh-add-login.sh
Type=Application
X-KDE-AutostartScript=true

Hope that helps,

That your login shell is zsh is no matter to the running of that script. The first line of a script, called the “shebang”, tells the OS what interpreter to use. I normally stick to bash for scripts, unless they’re doing zsh things, mostly because sometimes I move scripts to other systems or containers that usually don’t have zsh installed.

1 Like