Skip to content

Instantly share code, notes, and snippets.

@iainlane
Created May 1, 2020 13:11
Show Gist options
  • Save iainlane/8653aa10baf651afe0638cb722baf4d8 to your computer and use it in GitHub Desktop.
Save iainlane/8653aa10baf651afe0638cb722baf4d8 to your computer and use it in GitHub Desktop.
am I in...?
using GLib;
private bool in_desktop (string desktop) {
var env = GLib.Environment.get_variable("XDG_CURRENT_DESKTOP");
if (env == null)
return false;
var desktop_parts = env.split(":");
return desktop in desktop_parts;
}
public int main (string[] args) {
print("Am I in GNOME? " + (in_desktop("GNOME") ? "yes" : "no") + "\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment