|
|
#1 | |
|
Registered User
Join Date: Jan 2011
Posts: 18
|
How can I fetch xserver version string in a clean format like: "1.9.0", and not cumbersome like Xorg -version output?
|
|
|
|
|
|
|
#2 | |
|
Registered User
Join Date: Dec 2008
Posts: 128
|
dpkg -l xserver-xorg-core |grep "^ii" |sed -n 's/.*:\([0-9.-]*\).*/\1/p'
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Jan 2011
Posts: 18
|
Hmm. I can't pipe it in C++ with popen(). Isn't there an easier way?
|
|
|
|
|
|
#4 | |
|
Registered User
Join Date: May 2006
Posts: 477
|
For a C/C++ program, you should be able to use the "VendorRelease()" function from Xlib.
|
|
|
|
|
|
|
#5 |
|
Registered User
Join Date: Jan 2011
Posts: 18
|
Thanks a zillion times.
|
|
|
|
|
|
#6 | |
|
Registered User
Join Date: Jan 2011
Posts: 18
|
#include <X11/Xlib.h>
QString xserverVersion; xserverVersion = XVendorRelease( XOpenDisplay( 0 ) ); Without any compilation and runtime errors, it returns "P" as the version string. What am I doing wrong? |
|
|
|
|
|
|
#7 |
|
Registered User
Join Date: May 2006
Posts: 477
|
Hm... You don't want a "QString" as XVendorRelease returns an int. Change xserverVersion to an int.
![]() |
|
|
|
|
|
#8 |
|
NVIDIA Corporation
Join Date: Mar 2005
Posts: 2,487
|
Parsing that number is hard. You'll probably want to lift the code xdpyinfo uses to identify the server vendor and then parse the release version based on that.
http://cgit.freedesktop.org/xorg/app...c80c86499#n241 |
|
|
|
|
|
#9 |
|
Registered User
Join Date: Jan 2011
Posts: 18
|
Thanks AaronP. I was able to parse the number by piping: xdpyinfo | grep "X.Org version" with popen() and doing the casual QString scissor operations with Qt. My app displays the version perfectly now as in Nvidia settings.
|
|
|
|
![]() |
| Thread Tools | |
|
|