[英]C++ / Qt: How can I detect when a hostname or IP address refers to the current system?
[英]How can I detect when I'm on a system running Unity?
为了选择用于程序的应用程序指示器类型,我需要检测我是否在Unity桌面中。 这可能吗? 当我无法访问环境时是否可能?
看起来还有XDG_CURRENT_DESKTOP:
rubiojr@rubiojr-VirtualBox:~$ echo $XDG_CURRENT_DESKTOP
Unity
请参阅https://askubuntu.com/questions/70296/is-there-an-environment-variable-that-is-set-for-unity
在Ubuntu中,您可以使用以下命令:
只是shell执行ps aux | grep unity
ps aux | grep unity
,这是linux的cross-plattform。 甚至适用于ARM内核。
在我的11.04 Ubuntu运行统一上它返回unity-2d-panel,unity-2d-launcher和更多进程。 无法确认每个Linux平台上是否都是这样。
通过运行以下命令行查看环境变量列表中的统一:
env | grep -i unity
如果您在此答案中看到XDG_CURRENT_DESKTOP=Unity
那么您就知道它正在使用中。 或者,您当然可以检查desktop
而不是unity
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.