Biont / sway-launcher-desktop

TUI Application launcher with Desktop Entry support. Made for SwayWM, but runs anywhere
GNU General Public License v3.0
607 stars 28 forks source link

Implement XDG Autostart OnlyShowIn and NotShowIn keys. #34

Open smsegal opened 3 years ago

smsegal commented 3 years ago

According to the XDG Desktop Autostart spec, a desktop file should only be autostarted in desktop environments matching the "OnlyShowIn" values.

Similarly for NotShowIn, the application should only be started in desktop environments not matching the given values.

This would be great as I woudn't manually have to set XDG_CONFIG_DIRS=$XDG_CONFIG_HOME before calling autostart, and can rely on this command to not start e.g the gnome welcome screen in my sway session while still starting applicable applications in /etc/xdg/autostart.

Biont commented 3 years ago

This makes a lot of sense. I hope I find the time to look at this soon. Meanwhile, PRs are of course welcome

Biont commented 3 years ago

Hm thinking about this: What DE is the script supposed to assume? The script itself works regardless of DE/WM, so I suppose this setting must be provided externally.

So we'd probably require this as either an ENV var or a direct function parameter, ie. sway-launcher-desktop autostart sway.

Thoughts? Maybe I'm on the wrong track. Is there some commonly used environment variable that we could read?

smsegal commented 3 years ago

Yeah, I was reading through the XDG spec and getting frustrated about this specific point. They have a list of approved keys to check against, but seem to leave it up the individual DE on how to actually do this.

XDG_CURRENT_DESKTOP seems like the right env var to check. Gnome sets this to "GNOME", and I believe the other main DE's do the same thing, although I can't find this documented as part of the XDG specs, and I haven't checked myself whether every DE listed in OnlyShowIn sets the variable in the same way.

FWIW, In my sway config, I set XDG_CURRENT_DESKTOP="sway".

Biont commented 3 years ago

Alright thanks for the research. I guess this is what it'll work against then