Page 1 of 1

[SOLVED] very strange startup issue

Posted: Monday 11th September 2023 9:00pm
by sadams54
This problem is strange. I am using fedora 36,37 and I am attempting to have a gambas written program come up at system start up/sign in. Some computers work flawlessly, others will not start the gambas written program. Now on one of the offending computers I have 2 gambas programs for startup. one of the programs starts without issue the other always fails. The program that starts always on this one will fail to start 50% of the time on another PC. I have not been able to figure out a pattern or why the programs fail at system start. They run if I select them without issue. I am hoping somebody here can point me towards something I have not thought of.

Re: very strange startup issue

Posted: Tuesday 12th September 2023 1:13am
by BruceSteers
did you set a startup delay?

this is how my $HOME/.config/autostart/Desktop-ish.desktop file looks...

Code: Select all

[Desktop Entry]
Type=Application
Exec=/media/bonus/SSDiskspace/git/Desktop-ish/Desktop-ish.gambas
Hidden=false
Name=Desktop-ish
X-MATE-Autostart-Enabled=true
X-MATE-Autostart-Delay=3
X-GNOME-Autostart-Enabled=true
X-GNOME-Autostart-Delay=3
Sometimes a gambas application can start before all it's requirements have loaded (like the system tray for example)

By adding a delay it allows the other things to load first.

It's likely your programs have different requirements and for the one that usually starts they are usually already loaded but for the other they are not.

My X-MATE-Autostart-Delay seems to work at 3 seconds, you might need more on a slower machine like a Pi.

Re: very strange startup issue

Posted: Tuesday 12th September 2023 10:27am
by BruceSteers
Or you can add code to wait for the programs dependencies to load.

For example here is how one of my programs waits untill the Systray has loaded before it continues...


Public Sub _new()

  Dim bHasTray As Boolean, iRetries As Integer

  bHasTray = Desktop.HasSystemTray  ' check systray is loaded

  If Not bHasTray Then  ' if not then wait up to 60 seconds re-checking for systray every second.

    For c As Integer = 1 To 60
      Wait 1
      Inc iRetries
      bHasTray = Desktop.HasSystemTray
      If bHasTray Then Break
    Next
  Endif

  If bHasTray then
    Print "SystemTray is loaded after " & iRetries & " retries"
  Else
    Message.Error("SystemTray not found")
    Quit
  Endif

End


Re: very strange startup issue

Posted: Tuesday 12th September 2023 2:59pm
by cogier
I agree with Bruce, you need to delay the start of your program by a few seconds. I have a music program, MelodyBox, I wrote in Gambas (with extra features by Bruce) that needs a few seconds before starting it. This is easy in Linux Mint as there is a Startup Applications program that does the work.

Image

Re: very strange startup issue

Posted: Tuesday 12th September 2023 6:10pm
by sadams54
I am going to try the desktop file edit. I had never seen it done that way. I used gnome-tweak-tool to do the autostart and it does not provide for delay.

the options you provided do not work for me at all. They are ignored. I had to modify the exec line instead

Exec=bash -c "sleep 7 && myapp" seems to function as expected. Will let you know if the solution holds up.

so far day 2 and it is holding up. it's alive