idleonbench
idleonbench

Reputation: 97

Getting X display variables in current running process using c++

I have couple processes and each of them is in control of three monitors. I am currently using the POSIX operating system API gethostname() link in my program for getting the name of the current running process.

#include <unistd.h>
gethostname(name, sizeof name);

I would also want to be able to tell which X display that the process is running, such as getting the screen name, but preferably getting the display variables DISPLAY=0:0 or DISAPLY=0:1. Tried to look up the POSIX API but didn't seem to find anything that will help with my problem. Any ideas?

Upvotes: 1

Views: 114

Answers (1)

Sam Varshavchik
Sam Varshavchik

Reputation: 118310

You're looking for the getenv() function, which returns the values of environment variables. DISPLAY is just an environment variable.

Upvotes: 2

Related Questions