[英]How can I detect when I'm on a system running Unity?
In order to choose between what type of app indicators to use for a program, I need to detect whether I'm in a Unity desktop or not. 为了选择用于程序的应用程序指示器类型,我需要检测我是否在Unity桌面中。 Is this possible?
这可能吗? Is it possible when I don't have access to the environment?
当我无法访问环境时是否可能?
It looks like there's also XDG_CURRENT_DESKTOP: 看起来还有XDG_CURRENT_DESKTOP:
rubiojr@rubiojr-VirtualBox:~$ echo $XDG_CURRENT_DESKTOP
Unity
See https://askubuntu.com/questions/70296/is-there-an-environment-variable-that-is-set-for-unity 请参阅https://askubuntu.com/questions/70296/is-there-an-environment-variable-that-is-set-for-unity
In Ubuntu you can use following commands: 在Ubuntu中,您可以使用以下命令:
Just shell execute ps aux | grep unity
只是shell执行
ps aux | grep unity
ps aux | grep unity
, this is cross-plattform for linux. ps aux | grep unity
,这是linux的cross-plattform。 Even works on ARM cores. 甚至适用于ARM内核。
On my 11.04 Ubuntu running unity it returns unity-2d-panel, unity-2d-launcher and more processes. 在我的11.04 Ubuntu运行统一上它返回unity-2d-panel,unity-2d-launcher和更多进程。 Can't confirm if this is true on every linux platform.
无法确认每个Linux平台上是否都是这样。
Look in the list of environment variables for unity by running this command line: 通过运行以下命令行查看环境变量列表中的统一:
env | grep -i unity
If as in this answer you see XDG_CURRENT_DESKTOP=Unity
then you know it is in use. 如果您在此答案中看到
XDG_CURRENT_DESKTOP=Unity
那么您就知道它正在使用中。 Alternatively, you could of course check for desktop
rather than unity
. 或者,您当然可以检查
desktop
而不是unity
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.