Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 02-09-11, 04:43 PM   #1
coin-op-console
Registered User
 
coin-op-console's Avatar
 
Join Date: Jan 2011
Posts: 18
Default A way to get xserver version string?

How can I fetch xserver version string in a clean format like: "1.9.0", and not cumbersome like Xorg -version output?
coin-op-console is offline   Reply With Quote
Old 02-09-11, 05:08 PM   #2
primerib
Registered User
 
Join Date: Dec 2008
Posts: 128
Default Re: A way to get xserver version string?

dpkg -l xserver-xorg-core |grep "^ii" |sed -n 's/.*:\([0-9.-]*\).*/\1/p'
primerib is offline   Reply With Quote
Old 02-09-11, 05:47 PM   #3
coin-op-console
Registered User
 
coin-op-console's Avatar
 
Join Date: Jan 2011
Posts: 18
Default Re: A way to get xserver version string?

Hmm. I can't pipe it in C++ with popen(). Isn't there an easier way?
coin-op-console is offline   Reply With Quote
Old 02-09-11, 07:27 PM   #4
mooninite
Registered User
 
Join Date: May 2006
Posts: 477
Default Re: A way to get xserver version string?

For a C/C++ program, you should be able to use the "VendorRelease()" function from Xlib.
mooninite is offline   Reply With Quote
Old 02-10-11, 01:44 AM   #5
coin-op-console
Registered User
 
coin-op-console's Avatar
 
Join Date: Jan 2011
Posts: 18
Default Re: A way to get xserver version string?

Thanks a zillion times.
coin-op-console is offline   Reply With Quote
Old 02-10-11, 02:21 AM   #6
coin-op-console
Registered User
 
coin-op-console's Avatar
 
Join Date: Jan 2011
Posts: 18
Default Re: A way to get xserver version string?

#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?
coin-op-console is offline   Reply With Quote
Old 02-10-11, 03:11 PM   #7
mooninite
Registered User
 
Join Date: May 2006
Posts: 477
Default Re: A way to get xserver version string?

Hm... You don't want a "QString" as XVendorRelease returns an int. Change xserverVersion to an int.
mooninite is offline   Reply With Quote
Old 02-10-11, 10:19 PM   #8
AaronP
NVIDIA Corporation
 
AaronP's Avatar
 
Join Date: Mar 2005
Posts: 2,487
Default Re: A way to get xserver version string?

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
AaronP is offline   Reply With Quote

Old 02-11-11, 11:46 AM   #9
coin-op-console
Registered User
 
coin-op-console's Avatar
 
Join Date: Jan 2011
Posts: 18
Default Re: A way to get xserver version string?

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.
coin-op-console is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:05 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.