Improvements to autostart
Posted on January 19, 2025, under Whisker Menu
When I added support for autostarting applications to Whisker Menu, I did not feel like handling the cases where the autostarted application had been disabled or there was a system-wide autostarted application.
But…
It just kept niggling at me. I had expected it would make the code brittle and extremely complicated, so I hadn’t given it too much thought. However, it always bothers me to write incomplete code that doesn’t handle reasonable edge cases. And it turns out I was wrong! The new code is quite clean and simple, really.
Handling disabled autostart
The way I had before checked if there was an autostarted application was to simply look to see if the launcher existed in $XDG_CONFIG_HOME/autostart/
. If I found it, I assumed that it was a valid launcher file, and therefore the application was autostarted.
However! You can disable autostarted applications by adding Hidden=true
to the file, which means it shouldn’t show up as autostarted in Whisker Menu. How often will people do this? I don’t know, but as Xfce makes it easy to disable an autostarted application, it isn’t out of the question.
Handling global autostart
And you can have system-wide autostarted applications. It would be silly for Whisker Menu to allow you to add the same application twice, but since it only checked the user’s autostart directory, it was a valid possibility. Probably a lot smaller possibility than disabling the launcher, but in fixing one I fixed both.
To prevent conflicts with autostarted filenames before I had added an extra whiskermenu-
to the start of the autostarted launcher filename. Now that it properly supports everything, it no longer does that. Which means I did break compatibility, but only for the people who have tried the git version of Whisker Menu in the past week. Sorry!
Ignoring other issues
Of course, there is one obvious situation this code doesn’t handle, and it was my issue with adding support for autostarted applications in the first place: it can’t tell if you have already added the same autostarted application before but with a different file name. Short of reading every single autostarted application launcher and checking for the same executable, there is no way to prevent that. Plus, that doesn’t even account for using symlinks as targets in launchers. So… the current code is as far as I am willing to go. 😉
But now I can finally breathe a sigh of relief and forget about the autostart code. 🙂