196
196
public bool IsAppropriateForCurrentDesktop {
198
// This check should eventually account for xfce too. Ideally here
199
// though, we wish to throw away certain items that are not useful to
200
// the current DE. We are using the same check that xdg-open uses.
201
if (!item.AttrExists ("OnlyShowIn")) return true;
203
string show_in = item.GetString ("OnlyShowIn").ToLower ();
204
return !show_in.Contains ("kde") ||
205
Environment.GetEnvironmentVariable ("KDE_FULL_SESSION") == "true";
198
string onlyShowIn = item.GetString ("OnlyShowIn");
199
string notShowIn = item.GetString ("NotShowIn");
200
string desktopSession = Environment.GetEnvironmentVariable ("XDG_CURRENT_DESKTOP");
202
if (desktopSession == null) {
204
// If KDE_FULL_SESSION is true, assume kde.
205
// Else, assume GNOME
206
if (Environment.GetEnvironmentVariable ("KDE_FULL_SESSION") == "true") {
207
desktopSession = "KDE";
209
desktopSession = "GNOME";
213
// It doesn't make sense for a DE to appear in both OnlyShowIn and
214
// NotShowIn. We choose to prefer OnlyShowIn in this case as it makes
215
// the following checks easier.
216
if (onlyShowIn != null) {
217
foreach (string environment in onlyShowIn.Split (';')) {
218
if (desktopSession.Equals (environment, StringComparison.InvariantCultureIgnoreCase)) {
222
// There's an OnlyShowIn attribute, and the current environment doesn't match.
226
if (notShowIn != null) {
227
foreach (string environment in notShowIn.Split (';')) {
228
if (desktopSession.Equals (environment, StringComparison.InvariantCultureIgnoreCase)) {