PDA

View Full Version : Determine Linux desktop version



RolandHughes
23rd June 2015, 17:58
All,

Before I go dumpster diving through a lot of VLC source to figure out how they do it, is there a Qt way to find out the desktop and version? How you turn off the lock screen and power save is different depending on desktop and version.

FDO_SS, /**< KDE >= 4 and GNOME >= 3.10 */
FDO_PM, /**< KDE and GNOME <= 2.26 */
MATE, /**< >= 1.0 */
GNOME, /**< GNOME 2.26..3.4 */

Not seeing anything off top of head so thought I would ask. There "should" be something somewhere, but too many classes to guess the name. Didn't see it in sysinfo.

wysota
23rd June 2015, 18:03
You can start with getenv("XDG_CURRENT_DESKTOP") and build from there (e.g. getenv("KDE_SESSION_VERSION")).

RolandHughes
23rd June 2015, 19:00
You can start with getenv("XDG_CURRENT_DESKTOP") and build from there (e.g. getenv("KDE_SESSION_VERSION")).

Thanks,

I knew there had to be something simple.

Actually, I don't know if I need to know it now. I "think" I can just send a QDBusMessage to each of the APIs. They will either exist or not. The routine is a one-shot deal to kill off the screen locker and power dimmer. I know, killing a mosquito with a shotgun blast, but sometimes it is just faster.

anda_skoa
23rd June 2015, 19:05
Most reasonably modern (<= 10 years) desktops will have those exposed as D-Bus interfaces.

As the snippet you posted indicates, the service names are likely org.freedesktop.ScreenSaver and org.freedesktop.PowerManagement (easily verfiyable using qdbusviewer or similar tools).

Cheers,
_