|
|
1.1 ! root 1: #include <X/mit-copyright.h> ! 2: ! 3: /* Copyright Massachusetts Institute of Technology 1985 */ ! 4: ! 5: #ifndef lint ! 6: static char *rcsid_xset_c = "$Header: xset.c,v 10.10 86/11/19 19:49:37 jg Rel $"; ! 7: #endif ! 8: ! 9: #include <X/Xlib.h> ! 10: #include <sys/types.h> ! 11: #include <stdio.h> ! 12: #include <netdb.h> ! 13: #include <netinet/in.h> ! 14: #include <strings.h> ! 15: ! 16: #define TRUE 1 ! 17: #define FALSE 0 ! 18: ! 19: main(argc, argv) ! 20: int argc; ! 21: char **argv; ! 22: { ! 23: char *disp = NULL; ! 24: register char *arg; ! 25: register int i; ! 26: int click, repeat, lock, bell, acc, thresh, video, timeout, cycle; ! 27: int doclick = FALSE, dorepeat = FALSE, dolock = FALSE; ! 28: int dobell = FALSE, domouse = FALSE, dosaver = FALSE; ! 29: int pixels[512]; ! 30: caddr_t colors[512]; ! 31: int numpixels = 0; ! 32: Color def; ! 33: ! 34: if (argc == 1) usage(argv[0]); ! 35: ! 36: for (i = 1; i < argc; ) { ! 37: arg = argv[i]; ! 38: i++; ! 39: if (strcmp(arg, "-c") == 0 || strcmp(arg, "-click") == 0) { ! 40: click = 0; ! 41: doclick = TRUE; ! 42: } else if (strcmp(arg, "c") == 0 || strcmp(arg, "click") == 0) { ! 43: click = 6; ! 44: doclick = TRUE; ! 45: if (i >= argc) ! 46: break; ! 47: arg = argv[i]; ! 48: if (strcmp(arg, "on") == 0) { ! 49: i++; ! 50: } else if (strcmp(arg, "off") == 0) { ! 51: click = 0; ! 52: i++; ! 53: } else if (*arg >= '0' && *arg <= '8') { ! 54: click = atoi(arg); ! 55: i++; ! 56: } ! 57: } else if (strcmp(arg, "-b") == 0 || strcmp(arg, "-bell") == 0) { ! 58: bell = 0; ! 59: dobell = TRUE; ! 60: } else if (strcmp(arg, "b") == 0 || strcmp(arg, "bell") == 0) { ! 61: bell = 6; ! 62: dobell = TRUE; ! 63: if (i >= argc) ! 64: break; ! 65: arg = argv[i]; ! 66: if (strcmp(arg, "on") == 0) { ! 67: i++; ! 68: } else if (strcmp(arg, "off") == 0) { ! 69: bell = 0; ! 70: i++; ! 71: } else if (*arg >= '0' && *arg <= '7') { ! 72: bell = atoi(arg); ! 73: i++; ! 74: } ! 75: } else if (strcmp(arg, "m") == 0 || strcmp(arg, "mouse") == 0) { ! 76: acc = 4; ! 77: thresh = 2; ! 78: domouse = TRUE; ! 79: if (i >= argc) ! 80: break; ! 81: arg = argv[i]; ! 82: if (strcmp(arg, "default") == 0) { ! 83: i++; ! 84: } else if (*arg >= '0' && *arg <= '9') { ! 85: acc = atoi(arg); ! 86: i++; ! 87: if (i >= argc) ! 88: break; ! 89: arg = argv[i]; ! 90: if (*arg >= '0' && *arg <= '9') { ! 91: thresh = atoi(arg); ! 92: i++; ! 93: } ! 94: } ! 95: } else if (strcmp(arg, "s") == 0 || strcmp(arg, "saver") == 0 || ! 96: strcmp(arg, "v") == 0 || strcmp(arg, "video") == 0) { ! 97: timeout = 10; ! 98: cycle = 60; ! 99: video = *arg == 's' ? 1 : 0; ! 100: dosaver = TRUE; ! 101: if (i >= argc) ! 102: break; ! 103: arg = argv[i]; ! 104: if (strcmp(arg, "default") == 0) { ! 105: i++; ! 106: } else if (*arg >= '0' && *arg <= '9') { ! 107: timeout = atoi(arg); ! 108: i++; ! 109: if (i >= argc) ! 110: break; ! 111: arg = argv[i]; ! 112: if (*arg >= '0' && *arg <= '9') { ! 113: cycle = atoi(arg); ! 114: i++; ! 115: } ! 116: } ! 117: } else if (strcmp(arg, "-r") == 0 || strcmp(arg, "-repeat") == 0) { ! 118: repeat = FALSE; ! 119: dorepeat = TRUE; ! 120: } else if (strcmp(arg, "r") == 0 || strcmp(arg, "repeat") == 0) { ! 121: repeat = TRUE; ! 122: dorepeat = TRUE; ! 123: if (i >= argc) ! 124: break; ! 125: arg = argv[i]; ! 126: if (strcmp(arg, "on") == 0) { ! 127: i++; ! 128: } else if (strcmp(arg, "off") == 0) { ! 129: repeat = FALSE; ! 130: i++; ! 131: } ! 132: } else if (strcmp(arg, "-l") == 0 || strcmp(arg, "-lock") == 0) { ! 133: lock = FALSE; ! 134: dolock = TRUE; ! 135: } else if (strcmp(arg, "l") == 0 || strcmp(arg, "lock") == 0) { ! 136: lock = TRUE; ! 137: dolock = TRUE; ! 138: if (i >= argc) ! 139: break; ! 140: arg = argv[i]; ! 141: if (strcmp(arg, "on") == 0) { ! 142: i++; ! 143: } else if (strcmp(arg, "off") == 0) { ! 144: lock = FALSE; ! 145: i++; ! 146: } ! 147: } else if (strcmp(arg, "p") == 0 || strcmp(arg, "pixel") == 0) { ! 148: if (i + 1 >= argc) ! 149: usage(argv[0]); ! 150: arg = argv[i]; ! 151: if (*arg >= '0' && *arg <= '9') ! 152: pixels[numpixels] = atoi(arg); ! 153: else ! 154: usage(argv[0]); ! 155: i++; ! 156: colors[numpixels] = argv[i]; ! 157: i++; ! 158: numpixels++; ! 159: } else if (index(arg, ':')) { ! 160: disp = arg; ! 161: } else ! 162: usage(argv[0]); ! 163: } ! 164: if (!doclick && !dorepeat && !dolock && !dobell && !domouse && !dosaver && ! 165: numpixels == 0) ! 166: usage(argv[0]); ! 167: ! 168: if (XOpenDisplay(disp) == NULL) { ! 169: fprintf(stderr, "%s: Can't open display '%s'\n", ! 170: argv[0], XDisplayName(disp)); ! 171: exit(1); ! 172: } ! 173: if (doclick) XKeyClickControl(click); ! 174: if (dolock) { ! 175: if (lock) XLockToggle(); ! 176: else XLockUpDown(); ! 177: } ! 178: if (dorepeat) { ! 179: if (repeat) XAutoRepeatOn(); ! 180: else XAutoRepeatOff(); ! 181: } ! 182: if (dobell) XFeepControl(bell); ! 183: if (domouse) XMouseControl(acc, thresh); ! 184: if (dosaver) XScreenSaver(timeout, cycle, video); ! 185: if (DisplayCells() >= 2) { ! 186: while (--numpixels >= 0) { ! 187: def.pixel = pixels[numpixels]; ! 188: if (XParseColor(colors[numpixels], &def)) ! 189: XStoreColor(&def); ! 190: else ! 191: fprintf(stderr, "%s: No such color\n", colors[numpixels]); ! 192: } ! 193: } ! 194: XSync(0); ! 195: exit(0); ! 196: } ! 197: ! 198: usage(prog) ! 199: char *prog; ! 200: { ! 201: printf("usage: %s option [option ...] [host:vs]\n", prog); ! 202: printf(" To turn bell off:\n"); ! 203: printf("\t-b b off b 0\n"); ! 204: printf(" To set bell volume:\n"); ! 205: printf("\t b [1-7] b on\n"); ! 206: printf(" To turn keyclick off:\n"); ! 207: printf("\t-c c off c 0\n"); ! 208: printf(" To set keyclick volume:\n"); ! 209: printf("\t c [1-8] c on\n"); ! 210: printf(" To turn shift-lock key off or on:\n"); ! 211: printf("\t-l l off\n"); ! 212: printf("\t l l on\n"); ! 213: printf(" To set mouse acceleration and threshold:\n"); ! 214: printf("\t m [acc [thr]] m default\n"); ! 215: printf(" To set pixel colors:\n"); ! 216: printf("\t p pixel_value color_name\n"); ! 217: printf(" To turn auto-repeat off or on:\n"); ! 218: printf("\t-r r off\n"); ! 219: printf("\t r r on\n"); ! 220: printf(" To make the screen-saver display a pattern:\n"); ! 221: printf("\t s [timeout [cycle]] s default\n"); ! 222: printf(" To make the screen-saver blank the video:\n"); ! 223: printf("\t v [timeout [cycle]] v default\n"); ! 224: exit(0); ! 225: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.