How to determine unity or gnome-shell or something else is running in C
Didier Roche
didrocks at ubuntu.com
Wed Oct 5 14:01:44 UTC 2011
Le 05/10/2011 15:50, Jeff Lane a écrit :
> On 10/05/2011 02:30 AM, Didier Roche wrote:
>> Le 05/10/2011 08:17, YunQiang Su a écrit :
>>> I am trying to make a program has different tray in different
>>> environment:
>>> when indicator is supported, indicator plug-in is used,
>>> when in gnome-shell or gnome-panel, notification area written by gtk
>>> when KDE, use the way KDE prefer,
>>>
>>> Then the problem is that how I can determine which are using dynamic?
>>> unity, gnome-shell or something else ?
>>>
>>>
>> You can detect Unity using dbus. There is a Bus Name
>> com.canonical.Unity.Launcher which is there only when Unity is running.
>> This method is 100% reliable compared to session name
>> (DESKTOP_SESSION=ubuntu, DESKTOP_SESSION=ubuntu-2d…) which isn't cross
>> distribution.
>>
>> For other like gnome-shell, I'm not sure if something similar exists.
>
> Didier,
>
> Is there a specific dbus method for determining 3D vs 2D? We
> previously were simply looking for com.canonical.Unity since at that
> time, Unity only ran in 3D, with Gnome begin the fallback. Now that
> we have both 3D and 2D, how can we make that determination. It would
> be useful in testing to know if the installation is providing 3d or 2d
> by default.
>
Interesting question! There is nothing "official" right now, but only 3D
has the Debug method right now, so you can base on that:
com.canonical.Unity,
/com/canonical/Unity/Debug
use the interface com.canonical.Unity.Debug.Introspection and GetState()
method.
You should open a wishlist so that we can add a common dbus method
returning 2D or 3D (and raise it at UDS if possible) so that it's on the
list.
For ubuntu only from Oneiric, you can rely on the DESKTOP_SESSION
environment variable being "ubuntu" for unity 3D and "ubuntu-2d" for
unity 2D. (the detection is done before choosing the session). That
won't tell you if the ui crashed at startup though.
Didier
More information about the Ubuntu-devel-discuss
mailing list