Program got turned off seconds after startup by bash script

I am having this script to turn on some programs at startup

#!/usr/bin/bash

#yakuake
# programs
function startProgs() {
    arr=("$@")
    for value in "${arr[@]}"
    do
        #run without output
        $value > /dev/null 2>&1 & 
    done
}


progArr=(
    "yakuake"
    "ibus-daemon -drx"
    "warp-taskbar"
)
startProgs "${progArr[@]}"

And script is set up in setting here
image

While the script did turn on these programs at startup, they only last for seconds before getting turned off. Note that if i run the script normally from terminal, they worked just fine.

What should I do to prevent them from being off like so?

Thank you in advance

===

  • Desktop KDE Plasma

KDE is probably not finished their session-start, when the script gets run, so you could implement a delay of time before starting it, or a condition to be met (like after x or y is loaded), before starting the script.

Does it need a “&” and a may be disown? after the script finishes, then all started processes will terminate.

startProgs "${progArr[@]}& disown"
2 Likes

@anon11595408 , @xircon I tried both approaches and seems only delaying for a bit time worked for me.

Thanks u both for the help :smiley:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.