简体   繁体   English

如何检测 Linux OS 是使用 KDE 还是 Gnome 环境

[英]How to detect if Linux OS uses KDE or Gnome environment

I need to programatically determine which window manager is running, on Linux.我需要以编程方式确定在 Linux 上运行的是哪个窗口管理器。

Pseudocode for how it would be used:如何使用它的伪代码:

if(WindowManagerOfOS.isKDE()){
      do.anyThing();
}

How can I do this?我怎样才能做到这一点? Is it even possible?甚至有可能吗?

System.getenv("XDG_CURRENT_DESKTOP")

returns "GNOME" on my machine.在我的机器上返回"GNOME" Try it out on KDE-based box.在基于 KDE 的盒子上尝试一下。

See also也可以看看

The official answer is that you aren't supposed to care.官方的回答是你不应该关心。 Both desktops honor existing standards.这两款台式机都遵循现有标准。 Both can run each others' software.两者都可以运行彼此的软件。 What is it you are trying to do?你想做什么? If it's a particular service you are looking for that only one distribution ships by default, you should be probing for that instead.如果它是您正在寻找的特定服务,并且默认情况下只有一个发行版,那么您应该探索它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM