From b6498656ae9f7dee3ca2022fdcae5394008936c1 Mon Sep 17 00:00:00 2001 From: runge Date: Sat, 7 Apr 2007 21:39:20 +0000 Subject: [PATCH] x11vnc: add gnome, kde, etc. FINDCREATEDISPLAY tags. --- x11vnc/ChangeLog | 4 ++++ x11vnc/README | 7 +++++-- x11vnc/help.c | 5 ++++- x11vnc/ssltools.h | 22 +++++++++++++++++++--- x11vnc/user.c | 23 +++++++++++++++++++---- x11vnc/userinput.c | 23 +++++++++++++++++------ x11vnc/x11vnc.1 | 5 ++++- 7 files changed, 72 insertions(+), 17 deletions(-) diff --git a/x11vnc/ChangeLog b/x11vnc/ChangeLog index 36f76ba..ea6b358 100644 --- a/x11vnc/ChangeLog +++ b/x11vnc/ChangeLog @@ -1,3 +1,7 @@ +2007-04-07 Karl Runge + * x11vnc: add gnome, kde, etc. FINDCREATEDISPLAY tags. + In check_ncache periodically check for changed desktop. + 2007-03-24 Karl Runge * x11vnc: reverse SSL connections. -sleepin option. diff --git a/x11vnc/README b/x11vnc/README index 873f75f..97a6664 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -1,5 +1,5 @@ -x11vnc README file Date: Fri Apr 6 15:54:32 EDT 2007 +x11vnc README file Date: Fri Apr 6 23:19:54 EDT 2007 The following information is taken from these URLs: @@ -11415,7 +11415,10 @@ Options: (or ge=). This only has an effect in FINDCREATEDISPLAY mode when a virtual X server such as Xvfb is going to be created. It sets the width and height of the new - display, and optionally the color depth as well. + display, and optionally the color depth as well. You + can also supply "kde", "gnome", "fvwm", "twm", + or "failsafe" to have the created display use that + mode for the user session. To disable the option setting set the environment variable X11VNC_NO_UNIXPW_OPTS=1 before starting x11vnc. diff --git a/x11vnc/help.c b/x11vnc/help.c index 5092230..25390c1 100644 --- a/x11vnc/help.c +++ b/x11vnc/help.c @@ -817,7 +817,10 @@ void print_help(int mode) { " (or ge=). This only has an effect in FINDCREATEDISPLAY\n" " mode when a virtual X server such as Xvfb is going to\n" " be created. It sets the width and height of the new\n" -" display, and optionally the color depth as well.\n" +" display, and optionally the color depth as well. You\n" +" can also supply \"kde\", \"gnome\", \"fvwm\", \"twm\",\n" +" or \"failsafe\" to have the created display use that\n" +" mode for the user session.\n" "\n" " To disable the option setting set the environment\n" " variable X11VNC_NO_UNIXPW_OPTS=1 before starting x11vnc.\n" diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h index 19c1926..ea26478 100644 --- a/x11vnc/ssltools.h +++ b/x11vnc/ssltools.h @@ -954,6 +954,22 @@ char create_display[] = " echo \"$session\"\n" " return\n" " fi\n" +" if [ \"X$have_gnome_session\" != \"X\" -a \"X$FD_SESS\" = \"Xgnome\" ]; then\n" +" echo \"$have_gnome_session\"\n" +" return\n" +" elif [ \"X$have_startkde\" != \"X\" -a \"X$FD_SESS\" = \"Xkde\" ]; then\n" +" echo \"$have_startkde\"\n" +" return\n" +" elif [ \"X$have_twm\" != \"X\" -a \"X$FD_SESS\" = \"Xtwm\" ]; then\n" +" echo \"$have_twm\"\n" +" return\n" +" elif [ \"X$have_fvwm2\" != \"X\" -a \"X$FD_SESS\" = \"Xfvwm\" ]; then\n" +" echo \"$have_fvwm2\"\n" +" return\n" +" elif [ \"X$have_xterm\" != \"X\" -a \"X$FD_SESS\" = \"Xfailsafe\" ]; then\n" +" echo \"$have_xterm\"\n" +" return\n" +" fi\n" " home=`csh -f -c \"echo ~$USER\"`\n" " if [ \"X$home\" = \"X\" -o ! -d \"$home\" ]; then\n" " if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n" @@ -1173,7 +1189,7 @@ char create_display[] = " if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n" " if [ \"X$have_root\" = \"X\" ]; then\n" " nohup sh -c \"(\n" -" sleep 6;\n" +" sleep 10;\n" " $have_xmodmap -display :$N -e 'keycode any = Shift_R' \\\n" " -e 'add Shift = Shift_L Shift_R' \\\n" " -e 'keycode any = Control_R' \\\n" @@ -1186,7 +1202,7 @@ char create_display[] = " )\" 1>&2 &\n" " else\n" " (\n" -" sleep 1;\n" +" sleep 6;\n" " $have_xmodmap -display :$N -e 'keycode any = Shift_R' \\\n" " -e 'add Shift = Shift_L Shift_R' \\\n" " -e 'keycode any = Control_R' \\\n" @@ -1288,7 +1304,7 @@ char create_display[] = " p_ok=1\n" "fi\n" "\n" -"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb xauth mcookie md5sum xmodmap startkde gnome-session blackbox fvwm mwm openbox twm windowmaker metacity X Xorg XFree86 Xsun Xsession netstat\n" +"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb xauth mcookie md5sum xmodmap startkde gnome-session blackbox fvwm2 mwm openbox twm windowmaker metacity X Xorg XFree86 Xsun Xsession netstat\n" "do\n" " p2=`echo \"$prog\" | sed -e 's/-/_/g'`\n" " eval \"have_$p2=''\"\n" diff --git a/x11vnc/user.c b/x11vnc/user.c index cb2853f..a5ea46c 100644 --- a/x11vnc/user.c +++ b/x11vnc/user.c @@ -1505,7 +1505,7 @@ if (0) db = 1; if (strstr(cmd, "FINDCREATEDISPLAY") == cmd) { char *opts = strchr(cmd, '-'); char st[] = ""; - char geom[32]; + char geom[32], xsess[32]; if (opts) { opts++; if (strstr(opts, "xdmcp")) { @@ -1515,6 +1515,7 @@ if (0) db = 1; opts = st; } sprintf(geom, "NONE"); + xsess[0] = '\0'; #if 0 if (!keep_unixpw_opts) { fprintf(stderr, "no keep_unixpw_opts\n"); @@ -1524,6 +1525,17 @@ if (!keep_unixpw_opts) { #endif if (unixpw && keep_unixpw_opts && keep_unixpw_opts[0] != '\0') { char *q, *p, *t = strdup(keep_unixpw_opts); + if (strstr(t, "gnome")) { + sprintf(xsess, "gnome"); + } else if (strstr(t, "kde")) { + sprintf(xsess, "kde"); + } else if (strstr(t, "twm")) { + sprintf(xsess, "twm"); + } else if (strstr(t, "fvwm")) { + sprintf(xsess, "fvwm"); + } else if (strstr(t, "failsafe")) { + sprintf(xsess, "failsafe"); + } q = strstr(t, "ge="); if (! q) q = strstr(t, "geom="); if (! q) q = strstr(t, "geometry="); @@ -1555,15 +1567,18 @@ if (!keep_unixpw_opts) { free(t); } set_env("FD_GEOM", geom); + set_env("FD_SESS", xsess); if (unixpw && keep_unixpw_user) { create_cmd = (char *) malloc(strlen(tmp) - + strlen("env USER='' /bin/sh ") + + strlen("env USER='' ") + + strlen("env FD_SESS='' ") + strlen("env FD_GEOM='' /bin/sh ") + strlen(keep_unixpw_user) + 1 + strlen(geom) + 1 + + strlen(xsess) + 1 + strlen(opts) + 1); - sprintf(create_cmd, "env USER='%s' FD_GEOM='%s' /bin/sh %s %s", - keep_unixpw_user, geom, tmp, opts); + sprintf(create_cmd, "env USER='%s' FD_GEOM='%s' FD_SESS='%s' /bin/sh %s %s", + keep_unixpw_user, geom, xsess, tmp, opts); } else { create_cmd = (char *) malloc(strlen(tmp) + strlen("/bin/sh ") + 1 + strlen(opts) + 1); diff --git a/x11vnc/userinput.c b/x11vnc/userinput.c index 4d86667..5fd37ae 100644 --- a/x11vnc/userinput.c +++ b/x11vnc/userinput.c @@ -8062,6 +8062,9 @@ void set_ncache_xrootpmap(void) { if (use_solid_bg) { image = solid_image(NULL); + if (!quiet) { + rfbLog("set_ncache_xrootpmap: solid_image\n"); + } } else if (pmap != None) { Pixmap pixmap = None; unsigned char *d_pmap; @@ -8079,8 +8082,9 @@ void set_ncache_xrootpmap(void) { rfbLog("set_ncache_xrootpmap: loading background pixmap: 0x%lx\n", pixmap); } } else { - rfbLog("set_ncache_xrootpmap: trying root background\n"); - + if (!quiet) { + rfbLog("set_ncache_xrootpmap: trying root background\n"); + } } if (image == NULL) { image = solid_root((char *) 0x1); @@ -8971,12 +8975,19 @@ if (hack_val == 2) { n = 0; ttot = 0; - if (dt_guess == NULL || now > dt_last + 30) { - if (dt_guess) { - free(dt_guess); - } + if (dt_guess == NULL || now > dt_last + 60) { + static char *dt_prev = NULL; + dt_prev = dt_guess; dt_guess = strdup(guess_desktop()); + if (ncache_xrootpmap && dt_prev && dt_guess) { + if (strcmp(dt_prev, dt_guess)) { + set_ncache_xrootpmap(); + } + } dt_last = now; + if (dt_prev) { + free(dt_prev); + } } if (dt_guess && !strcmp(dt_guess, "gnome")) { dt_gnome = 1; diff --git a/x11vnc/x11vnc.1 b/x11vnc/x11vnc.1 index 650f273..831b040 100644 --- a/x11vnc/x11vnc.1 +++ b/x11vnc/x11vnc.1 @@ -962,7 +962,10 @@ Another option is "geom=WxH" or "geom=WxHxD" (or ge=). This only has an effect in FINDCREATEDISPLAY mode when a virtual X server such as Xvfb is going to be created. It sets the width and height of the new -display, and optionally the color depth as well. +display, and optionally the color depth as well. You +can also supply "kde", "gnome", "fvwm", "twm", +or "failsafe" to have the created display use that +mode for the user session. .IP To disable the option setting set the environment variable X11VNC_NO_UNIXPW_OPTS=1 before starting x11vnc.