简体   繁体   English

如何检测运行Unity的系统何时运行?

[英]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中,您可以使用以下命令:

  • echo $DESKTOP_SESSION : This command return ubuntu when you are using Unity and ubuntu-2d when you are using Unity 2D and ... echo $ DESKTOP_SESSION :当你使用Unity和ubuntu-2d时,当你使用Unity 2D时,这个命令返回ubuntu ...
  • sudo grep "Starting session" /var/log/lightdm/lightdm.log : Because of last version of Ubuntu use lightdm as display manager you can see last line of the lightdm.log file. sudo grep“Starting session”/var/log/lightdm/lightdm.log :由于上一版本的Ubuntu使用lightdm作为显示管理器,你可以看到lightdm.log文件的最后一行

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.

相关问题 C++/Qt:如何检测主机名或 IP 地址何时引用当前系统? - C++ / Qt: How can I detect when a hostname or IP address refers to the current system? 如何检测程序是否在 valgrind 中运行? - How can I detect if a program is running from within valgrind? 在Qt GUI事件线程中检测到“我正在运行” - Detect that “I'm running” in Qt GUI event thread 如何检测我是否正在用 C++ 编译 64 位架构 - How can I detect if I'm compiling for a 64bits architecture in C++ 如何判断我正在运行的Microsoft C ++代码是使用/ EHa开关编译的? - How can I tell if the Microsoft C++ code I'm running was compiled with the /EHa switch? 如何检测 SD 卡何时插入? - How can I detect when an SD card is plugged in? 如何以编程方式检测当前系统上是否已安装MSMQ? - How can I programmatically detect if MSMQ has been installed on the current system? 如何检测两个文件条目是否使用Qt引用相同的物理文件系统? - How can I detect if two file entries refer to the same physical file system with Qt? 系统(“暂停”)无法正常工作,有人可以看到我所缺少的内容吗? - system(“pause”) not working, can anyone see what I'm missing? 如何检测我是否正在使用特定的 Visual Studio 版本编译代码? - How to Detect if I'm Compiling Code with a particular Visual Studio version?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM