diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-07-20 17:41:32 -0400 |
---|---|---|
committer | William Jon McCann <mccann@jhu.edu> | 2007-07-20 17:41:32 -0400 |
commit | f6027221567fcb9ead1823e2da4eb9783f2db9ce (patch) | |
tree | 9904c90211832af8cc999b9b1dd716f70d60bc29 /tools | |
parent | a9aa00ff0fea79452a60a2448dd1f2714918884a (diff) |
Add --display option to tool.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linux/ck-get-x11-display-device.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tools/linux/ck-get-x11-display-device.c b/tools/linux/ck-get-x11-display-device.c index c0d3772..2d414c6 100644 --- a/tools/linux/ck-get-x11-display-device.c +++ b/tools/linux/ck-get-x11-display-device.c @@ -84,12 +84,13 @@ get_peer_pid (int fd) } static Display * -display_init (int *argc, char ***argv) +display_init (char *display_name) { - const char *display_name; Display *xdisplay; - display_name = g_getenv ("DISPLAY"); + if (display_name == NULL) { + display_name = g_getenv ("DISPLAY"); + } if (display_name == NULL) { g_warning ("DISPLAY is not set"); @@ -112,10 +113,23 @@ main (int argc, int fd; int ret; Display *xdisplay; + static char *display = NULL; + GError *error; + GOptionContext *context; + static GOptionEntry entries [] = { + { "display", 0, 0, G_OPTION_ARG_STRING, &display, "display name", NULL }, + { NULL } + }; ret = 1; - xdisplay = display_init (&argc, &argv); + context = g_option_context_new (NULL); + g_option_context_add_main_entries (context, entries, NULL); + error = NULL; + ret = g_option_context_parse (context, &argc, &argv, &error); + g_option_context_free (context); + + xdisplay = display_init (display); fd = ConnectionNumber (xdisplay); |