slack.sh: Ensure existence of secret service
Slack stores its token in the keyring and reads from it at application start (in the same way as chromium).
We can have cases where the secret service does not exist at some point of time, because the keyring provider is another non-DE program, like keepassxc.
And this can especially happen on startup - both keepassxc and Slack would be startup applications, and there is no ordering enforced by (let's say) GNOME.
Keyring is available for access only when keepassxc gets started. So it must start earlier. But due to lack of ordering, Slack could start before keepassxc.
Since Slack won the race, it can't use the secret service (i.e. the keyring access would fail), and thus can't see the token.
When that happens, Slack resets the session. And even upon subsequent availability of the secret service, Slack does not restore the session, even after gaining access to the keyring / token - the destruction of the session is stored somewhere outside I think, so it disregards the token or does not attempt to connect using it.
So let's ensure the existence of the keyring before actually starting Slack.
Yes, this is kind of an upstream bug, but we can "fix" this up in our scripts.
🚧 Test build enqueued.
🚧 Started test build.
What I currently do to mitigate the startup race is to use a wrapper script which calls flatpak after a sleep of 5 seconds.
But I think it's better if we can just add it in here for a more general mitigation.
I am a noob to flatpak dev, so I did not test this though. Please let me know if I put this in the wrong place.
🚧 Test build succeeded. To test this build, install it from the testing repository:
flatpak install --user https://dl.flathub.org/build-repo/187956/com.slack.Slack.flatpakref