To: xbugs@expo.lcs.mit.edu, xpert@expo.lcs.mit.edu Subject: clients/xset: fixes and additional code to produce parseable output VERSION: R5, public-patch-14 CLIENT MACHINE and OPERATING SYSTEM: Sparc/SunOS 4.1.1 DISPLAY TYPE: WINDOW MANAGER: COMPILER: AREA: clients/xset SYNOPSIS: Additional code to have xset produce output it can accept itself. Also some trivial fixes. DESCRIPTION: I adjust mouse-acceleration and font-path and screen-saver values fairly often; in order to save settings, I've used "xset q" and pasted the values into my .xsession file with the appropriate xset option name. This is a simple way to save the state of the server settings for use later; e.g. optimally as simple as % xset q reparse > file and include file in ~/.xsession or ~/.xinitrc. (Certain aspects of the saved settings may apply to only the server from which they are derived.) Also fixed: missing documentation for "[-]r keyboard" although that feature doesn't appear to be implemented by the sample server [?] missing documentation for "s off [off]" REPEAT BY: I wanted this functionality in part because I had problems figuring out the correspondence between the long "xset q" printed output and the options in order to reconstruct the set of server settings, which are increasingly fine-tuned; I don't care about the names of the options as long as I can repeat the values. SAMPLE FIX: Here are the diffs I'm using which add a new "xset q reparse" option, with these notes: - I attempted to change as little code as possible although the changes are added in-line and not nicely separated. - output is still somewhat clumsy; in particular, the new code isn't smart about packing output into as few lines as possible and so it winds up invoking xset far too many times - in general can't figure out server defaults so can't be smart about auto-resetting values to "default" instead of enumerating values (esp. led_mask and keyboard auto_repeat values) - "-display" not echoed back out David B. Lewis Yet another new address!: david%craft@uunet.uu.net "There are five stages of fame: denial, anger, negotiation, acceptance, and death. These stages are virtually the same as the five stages of terminal illness." -Nora Ephron *** xset.man.keep Sat Jul 27 18:40:09 1991 --- xset.man Fri Jul 31 20:04:28 1992 *************** *** 11,20 **** [[-]led [\fIinteger\fP]] [led on/off] [m[ouse] [\fIaccel_mult\fP[/\fIaccel_div\fP] [\fIthreshold\fP]]] [m[ouse] default] [p \fIpixel\fP \fIcolor\fP] ! [[-]r] [r on/off] [s [\fIlength\fP [\fIperiod\fP]]] [s blank/noblank] [s expose/noexpose] [s on/off] [s default] ! [q] .SH DESCRIPTION This program is used to set various user preference options of the display. .SH OPTIONS --- 11,20 ---- [[-]led [\fIinteger\fP]] [led on/off] [m[ouse] [\fIaccel_mult\fP[/\fIaccel_div\fP] [\fIthreshold\fP]]] [m[ouse] default] [p \fIpixel\fP \fIcolor\fP] ! [[-]r] [r on/off] [[-]r keycode] [s [\fIlength\fP [\fIperiod\fP]]] [s blank/noblank] [s expose/noexpose] [s on/off] [s default] ! [q [reparse]] .SH DESCRIPTION This program is used to set various user preference options of the display. .SH OPTIONS *************** *** 142,147 **** --- 142,148 ---- The \fBr\fP option controls the autorepeat. If a preceding dash or the 'off' flag is used, autorepeat will be disabled. If no parameters or the 'on' flag is used, autorepeat will be enabled. + A numeric value following r affects the repeat mode for that key only. .PP .TP 8 .B s *************** *** 163,169 **** The length and period parameters for the screen saver function determines how long the server must be inactive for screen saving to activate, and the period ! to change the background pattern to avoid burn in. The arguments are specified in seconds. If only one numerical parameter is given, it will be used for the length. .PP --- 164,171 ---- The length and period parameters for the screen saver function determines how long the server must be inactive for screen saving to activate, and the period ! to change the background pattern to avoid burn in ("xset s off off" sets ! both to 0). The arguments are specified in seconds. If only one numerical parameter is given, it will be used for the length. .PP *************** *** 170,175 **** --- 172,180 ---- .TP 8 .B q The \fBq\fP option gives you information on the current settings. + This option accepts a single 'reparse' flag which indicates that a subset + of the settings should be echoed in a format which xset can parse to + duplicate later the current server settings. .PP These settings will be reset to default values when you log out. .PP *** xset.c.keep Mon Jul 22 18:32:47 1991 --- xset.c Tue Aug 4 21:50:43 1992 *************** *** 379,385 **** set_lock(dpy, ON); } else if (strcmp(arg, "q") == 0 || strcmp(arg, "-q") == 0) { ! query(dpy); } else usage ("unknown option %s", arg); --- 379,396 ---- set_lock(dpy, ON); } else if (strcmp(arg, "q") == 0 || strcmp(arg, "-q") == 0) { ! if (i >= argc) { ! query (dpy, 0); ! break; ! } ! arg = nextarg(i, argv); ! if (0 == strcmp(argv[i], "reparse")) ! { ! query (dpy, 1); ! i++; ! } ! else ! query (dpy, 0); } else usage ("unknown option %s", arg); *************** *** 777,784 **** /* This is the information-getting function for telling the user what the * current "xsettings" are. */ ! query(dpy) Display *dpy; { int scr = DefaultScreen (dpy); XKeyboardState values; --- 788,796 ---- /* This is the information-getting function for telling the user what the * current "xsettings" are. */ ! query(dpy,reparse) Display *dpy; + int reparse; { int scr = DefaultScreen (dpy); XKeyboardState values; *************** *** 793,850 **** XGetScreenSaver(dpy, &timeout, &interval, &prefer_blank, &allow_exp); font_path = XGetFontPath(dpy, &npaths); ! printf ("Keyboard Control:\n"); ! printf (" auto repeat: %s key click percent: %d LED mask: %08lx\n", on_or_off (values.global_auto_repeat, AutoRepeatModeOn, "on", AutoRepeatModeOff, "off", buf), values.key_click_percent, values.led_mask); ! printf (" auto repeating keys: "); ! for (i = 0; i < 4; i++) { if (i) printf (" "); for (j = 0; j < 8; j++) { printf ("%02x", (unsigned char)values.auto_repeats[i*8 + j]); } printf ("\n"); ! } ! printf (" bell percent: %d bell pitch: %d bell duration: %d\n", values.bell_percent, values.bell_pitch, values.bell_duration); ! printf ("Pointer Control:\n"); ! printf (" acceleration: %d/%d threshold: %d\n", acc_num, acc_denom, threshold); ! printf ("Screen Saver:\n"); ! printf (" prefer blanking: %s ", on_or_off (prefer_blank, PreferBlanking, "yes", DontPreferBlanking, "no", buf)); ! printf ("allow exposures: %s\n", on_or_off (allow_exp, AllowExposures, "yes", DontAllowExposures, "no", buf)); ! printf (" timeout: %d cycle: %d\n", timeout, interval); ! printf ("Colors:\n"); ! printf (" default colormap: 0x%lx BlackPixel: %d WhitePixel: %d\n", DefaultColormap (dpy, scr), BlackPixel (dpy, scr), WhitePixel (dpy, scr)); ! printf ("Font Path:\n"); ! if (npaths) { ! printf( " %s", *font_path++ ); ! for( --npaths; npaths; npaths-- ) ! printf( ",%s", *font_path++ ); ! printf( "\n" ); ! } else { ! printf (" (empty)\n"); ! } #ifdef MITMISC { int dummy; if (XMITMiscQueryExtension(dpy, &dummy, &dummy)) { if (XMITMiscGetBugMode(dpy)) printf ("Bug Mode: compatibility mode is enabled\n"); else printf ("Bug Mode: compatibility mode is disabled\n"); } } #endif --- 805,976 ---- XGetScreenSaver(dpy, &timeout, &interval, &prefer_blank, &allow_exp); font_path = XGetFontPath(dpy, &npaths); ! if (reparse) ! { ! if (0 == values.key_click_percent) ! printf ("%s -c\n",progName); /* 0 is off */ ! else ! printf ("%s c %d\n", progName, values.key_click_percent); ! if (AutoRepeatModeOff == values.global_auto_repeat) ! printf ("%s r off\n", progName); ! else ! { ! int i,j,k; ! printf ("%s r on\n",progName); ! for (i = 0; i < 32; i++) ! for (j=1, k=0; j<=128; j *= 2, k++) ! { ! if (values.auto_repeats[i] & j) ! printf("%s r %d\n",progName, i*8 + k); ! /* really should reset all values to 1 or 0; in any ! ** case we really lose "default" behavior per-key ! */ ! /* ! else ! printf("%s -r %d\n",progName, i*8 + k); ! */ ! } ! } ! if (0 == values.led_mask) ! printf ("%s led off\n",progName); ! else ! { ! int i,j; ! /* must enumerate although could try turning all off or on and then ! ** flipping other ones depending on which is fewest; but on some servers ! ** the led_mask is ffffffff even if very few leds are lit, and can't ! ** distinguish cases. Anyway, these values are of dubious use. ! */ ! for (i = 1, j=1; i <= 32; i++, j *= 2) ! printf ("%s %sled %d\n",progName, ! (values.led_mask & j) ? " " : "-", i); ! } ! ! } ! else ! { ! printf ("Keyboard Control:\n"); ! printf (" auto repeat: %s key click percent: %d LED mask: %08lx\n", on_or_off (values.global_auto_repeat, AutoRepeatModeOn, "on", AutoRepeatModeOff, "off", buf), values.key_click_percent, values.led_mask); ! ! printf (" auto repeating keys: "); ! for (i = 0; i < 4; i++) { if (i) printf (" "); for (j = 0; j < 8; j++) { printf ("%02x", (unsigned char)values.auto_repeats[i*8 + j]); } printf ("\n"); ! } ! } ! ! if (reparse) ! { ! /* specify all; don't want to figure out server defaults */ ! printf ("%s b %d %d %d\n", progName, ! values.bell_percent, values.bell_pitch, values.bell_duration); ! } ! else ! { ! printf (" bell percent: %d bell pitch: %d bell duration: %d\n", values.bell_percent, values.bell_pitch, values.bell_duration); + } ! if (reparse) ! { ! /* specify all; don't want to figure out server defaults */ ! printf ("%s m %d/%d %d\n",progName, ! acc_num, acc_denom, threshold); ! } ! else ! { ! printf ("Pointer Control:\n"); ! printf (" acceleration: %d/%d threshold: %d\n", acc_num, acc_denom, threshold); + } ! if (reparse) ! { ! if (0 == timeout) ! { ! if (0 == interval) ! printf ("%s s off off\n",progName); ! else ! printf ("%s s off\n",progName); ! } ! else ! { ! printf ("%s s %s\n", progName, ! (PreferBlanking == prefer_blank) ? "blank" : "noblank"); ! printf ("%s s %s\n", progName, ! (AllowExposures == allow_exp) ? "expose" : "noexpose"); ! printf ("%s s %d %d\n", progName, timeout, interval); ! } ! } ! else ! { ! printf ("Screen Saver:\n"); ! printf (" prefer blanking: %s ", on_or_off (prefer_blank, PreferBlanking, "yes", DontPreferBlanking, "no", buf)); ! printf ("allow exposures: %s\n", on_or_off (allow_exp, AllowExposures, "yes", DontAllowExposures, "no", buf)); ! printf (" timeout: %d cycle: %d\n", timeout, interval); ! } ! if (reparse) ! { ! /* will likely cause BadAccess errors */ ! printf ("%s p %d black p %d white\n", progName, ! BlackPixel (dpy, scr), WhitePixel (dpy, scr)); ! } ! else ! { ! printf ("Colors:\n"); ! printf (" default colormap: 0x%lx BlackPixel: %d WhitePixel: %d\n", DefaultColormap (dpy, scr), BlackPixel (dpy, scr), WhitePixel (dpy, scr)); + } ! if (npaths) { ! if (reparse) ! { ! printf ("%s fp=",progName); ! } ! else ! { ! printf ("Font Path:\n"); ! } ! printf( " %s", *font_path++ ); ! for( --npaths; npaths; npaths-- ) ! printf( ",%s", *font_path++ ); ! printf( "\n" ); ! } else { ! if (!reparse) ! printf (" (empty)\n"); ! } + #ifdef MITMISC { int dummy; if (XMITMiscQueryExtension(dpy, &dummy, &dummy)) { if (XMITMiscGetBugMode(dpy)) + { + if (reparse) + printf ("%s bc\n",progName); + else printf ("Bug Mode: compatibility mode is enabled\n"); + } else + { + if (reparse) + printf ("%s -bc\n",progName); + else printf ("Bug Mode: compatibility mode is disabled\n"); + } } } #endif *************** *** 902,910 **** fprintf (stderr, "\t r [keycode] r on\n"); fprintf (stderr, " For screen-saver control:\n"); fprintf (stderr, "\t s [timeout [cycle]] s default s on\n"); ! fprintf (stderr, "\t s blank s noblank s off\n"); fprintf (stderr, "\t s expose s noexpose\n"); ! fprintf (stderr, " For status information: q\n"); exit(0); } --- 1028,1037 ---- fprintf (stderr, "\t r [keycode] r on\n"); fprintf (stderr, " For screen-saver control:\n"); fprintf (stderr, "\t s [timeout [cycle]] s default s on\n"); ! fprintf (stderr, "\t s blank s noblank s off [off]\n"); fprintf (stderr, "\t s expose s noexpose\n"); ! fprintf (stderr, " For status information:\n"); ! fprintf (stderr, "\t q [reparse]\n"); exit(0); }