![](/img/trans.png)
[英]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.