简体   繁体   中英

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. Is this possible? Is it possible when I don't have access to the environment?

It looks like there's also 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

In Ubuntu you can use following commands:

  • echo $DESKTOP_SESSION : This command return ubuntu when you are using Unity and ubuntu-2d when you are using Unity 2D and ...
  • 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.

Just shell execute ps aux | grep unity ps aux | grep unity , this is cross-plattform for linux. Even works on ARM cores.

On my 11.04 Ubuntu running unity it returns unity-2d-panel, unity-2d-launcher and more processes. Can't confirm if this is true on every linux platform.

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. Alternatively, you could of course check for desktop rather than unity .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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