755
777
CHECK("timestamp") type = pref_bool, b = p->timestamp_p;
756
778
CHECK("splash") type = pref_bool, b = p->splash_p;
757
779
CHECK("splashDuration") type = pref_time, t = p->splash_duration;
780
CHECK("quad") type = pref_bool, b = p->quad_p;
758
781
CHECK("demoCommand") type = pref_str, s = p->demo_command;
759
782
CHECK("prefsCommand") type = pref_str, s = p->prefs_command;
760
CHECK("helpURL") type = pref_str, s = p->help_url;
761
CHECK("loadURL") type = pref_str, s = p->load_url_command;
783
/* CHECK("helpURL") type = pref_str, s = p->help_url; */
784
CHECK("helpURL") continue; /* don't save */
785
/* CHECK("loadURL") type = pref_str, s = p->load_url_command; */
786
CHECK("loadURL") continue; /* don't save */
787
/* CHECK("newLoginCommand") type = pref_str, s = p->new_login_command; */
788
CHECK("newLoginCommand") continue; /* don't save */
762
789
CHECK("nice") type = pref_int, i = p->nice_inferior;
763
790
CHECK("memoryLimit") type = pref_byte, i = p->inferior_memory_limit;
764
791
CHECK("fade") type = pref_bool, b = p->fade_p;
767
794
CHECK("fadeTicks") type = pref_int, i = p->fade_ticks;
768
795
CHECK("captureStderr") type = pref_bool, b = p->capture_stderr_p;
769
796
CHECK("captureStdout") continue; /* don't save */
797
CHECK("ignoreUninstalledPrograms")
798
type = pref_bool, b = p->ignore_uninstalled_p;
770
800
CHECK("font") type = pref_str, s = stderr_font;
772
802
CHECK("dpmsEnabled") type = pref_bool, b = p->dpms_enabled_p;
779
809
CHECK("chooseRandomImages")type =pref_bool, b = p->random_image_p;
780
810
CHECK("imageDirectory") type =pref_str, s = p->image_directory;
812
CHECK("mode") type = pref_str,
813
s = (p->mode == ONE_HACK ? "one" :
814
p->mode == BLANK_ONLY ? "blank" :
815
p->mode == DONT_BLANK ? "off" :
816
p->mode == RANDOM_HACKS_SAME
819
CHECK("selected") type = pref_int, i = p->selected_hack;
821
CHECK("textMode") type = pref_str,
822
s = (p->tmode == TEXT_URL ? "url" :
823
p->tmode == TEXT_LITERAL ? "literal" :
824
p->tmode == TEXT_FILE ? "file" :
825
p->tmode == TEXT_PROGRAM ? "program" :
827
CHECK("textLiteral") type = pref_str, s = p->text_literal;
828
CHECK("textFile") type = pref_str, s = p->text_file;
829
CHECK("textProgram") type = pref_str, s = p->text_program;
830
CHECK("textURL") type = pref_str, s = p->text_url;
782
832
CHECK("programs") type = pref_str, s = programs;
783
833
CHECK("pointerPollTime") type = pref_time, t = p->pointer_timeout;
834
CHECK("pointerHysteresis")type = pref_int, i = p->pointer_hysteresis;
784
835
CHECK("windowCreationTimeout")type=pref_time,t= p->notice_events_timeout;
785
836
CHECK("initialDelay") type = pref_time, t = p->initial_delay;
786
837
CHECK("sgiSaverExtension")type = pref_bool, b=p->use_sgi_saver_extension;
787
CHECK("mitSaverExtension")type = pref_bool, b=p->use_mit_saver_extension;
838
CHECK("mitSaverExtension") continue; /* don't save */
788
839
CHECK("xidleExtension") type = pref_bool, b = p->use_xidle_extension;
789
840
CHECK("procInterrupts") type = pref_bool, b = p->use_proc_interrupts;
841
CHECK("GetViewPortIsFullOfLies") type = pref_bool,
842
b = p->getviewport_full_of_lies_p;
790
843
CHECK("overlayStderr") type = pref_bool, b = overlay_stderr_p;
791
844
CHECK("overlayTextBackground") continue; /* don't save */
792
845
CHECK("overlayTextForeground") continue; /* don't save */
976
1034
p->nice_inferior = get_integer_resource ("nice", "Nice");
977
1035
p->inferior_memory_limit = get_byte_resource ("memoryLimit", "MemoryLimit");
978
1036
p->splash_p = get_boolean_resource ("splash", "Boolean");
1037
p->quad_p = get_boolean_resource ("quad", "Boolean");
979
1038
p->capture_stderr_p = get_boolean_resource ("captureStderr", "Boolean");
1039
p->ignore_uninstalled_p = get_boolean_resource ("ignoreUninstalledPrograms",
981
1042
p->initial_delay = 1000 * get_seconds_resource ("initialDelay", "Time");
982
1043
p->splash_duration = 1000 * get_seconds_resource ("splashDuration", "Time");
999
1061
p->image_directory = get_string_resource ("imageDirectory",
1000
1062
"ImageDirectory");
1064
p->text_literal = get_string_resource ("textLiteral", "TextLiteral");
1065
p->text_file = get_string_resource ("textFile", "TextFile");
1066
p->text_program = get_string_resource ("textProgram", "TextProgram");
1067
p->text_url = get_string_resource ("textURL", "TextURL");
1002
1069
p->shell = get_string_resource ("bourneShell", "BourneShell");
1004
1071
p->demo_command = get_string_resource("demoCommand", "URL");
1005
1072
p->prefs_command = get_string_resource("prefsCommand", "URL");
1006
1073
p->help_url = get_string_resource("helpURL", "URL");
1007
1074
p->load_url_command = get_string_resource("loadURL", "LoadURL");
1075
p->new_login_command = get_string_resource("newLoginCommand",
1010
1078
/* If "*splash" is unset, default to true. */
1028
1096
p->use_xidle_extension = get_boolean_resource ("xidleExtension","Boolean");
1097
#if 0 /* ignore this, it is evil. */
1029
1098
p->use_mit_saver_extension = get_boolean_resource ("mitSaverExtension",
1031
1101
p->use_sgi_saver_extension = get_boolean_resource ("sgiSaverExtension",
1033
1103
p->use_proc_interrupts = get_boolean_resource ("procInterrupts", "Boolean");
1035
/* Throttle the various timeouts to reasonable values.
1037
if (p->passwd_timeout <= 0) p->passwd_timeout = 30000; /* 30 secs */
1038
if (p->timeout < 10000) p->timeout = 10000; /* 10 secs */
1039
if (p->cycle != 0 && p->cycle < 2000) p->cycle = 2000; /* 2 secs */
1040
if (p->pointer_timeout <= 0) p->pointer_timeout = 5000; /* 5 secs */
1041
if (p->notice_events_timeout <= 0)
1042
p->notice_events_timeout = 10000; /* 10 secs */
1043
if (p->fade_seconds <= 0 || p->fade_ticks <= 0)
1045
if (! p->fade_p) p->unfade_p = False;
1047
/* The DPMS settings may have the value 0.
1048
But if they are negative, or are a range less than 10 seconds,
1049
reset them to sensible defaults. (Since that must be a mistake.)
1051
if (p->dpms_standby != 0 &&
1052
p->dpms_standby < 10 * 1000)
1053
p->dpms_standby = 2 * 60 * 60 * 1000; /* 2 hours */
1054
if (p->dpms_suspend != 0 &&
1055
p->dpms_suspend < 10 * 1000)
1056
p->dpms_suspend = 2 * 60 * 60 * 1000; /* 2 hours */
1057
if (p->dpms_off != 0 &&
1058
p->dpms_off < 10 * 1000)
1059
p->dpms_off = 4 * 60 * 60 * 1000; /* 4 hours */
1061
if (p->dpms_standby == 0 && /* if *all* are 0, then DPMS is disabled */
1062
p->dpms_suspend == 0 &&
1064
p->dpms_enabled_p = False;
1067
p->watchdog_timeout = p->cycle * 0.6;
1068
if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000; /* 30 secs */
1069
if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /* 1 hr */
1071
get_screenhacks (p);
1105
p->getviewport_full_of_lies_p =
1106
get_boolean_resource ("GetViewPortIsFullOfLies", "Boolean");
1108
get_screenhacks (p); /* Parse the "programs" resource. */
1111
char *s = get_string_resource ("selected", "Integer");
1113
p->selected_hack = -1;
1115
p->selected_hack = get_integer_resource ("selected", "Integer");
1117
if (p->selected_hack < 0 || p->selected_hack >= p->screenhacks_count)
1118
p->selected_hack = -1;
1122
char *s = get_string_resource ("mode", "Mode");
1123
if (s && !strcasecmp (s, "one")) p->mode = ONE_HACK;
1124
else if (s && !strcasecmp (s, "blank")) p->mode = BLANK_ONLY;
1125
else if (s && !strcasecmp (s, "off")) p->mode = DONT_BLANK;
1126
else if (s && !strcasecmp (s, "random-same")) p->mode = RANDOM_HACKS_SAME;
1127
else p->mode = RANDOM_HACKS;
1132
char *s = get_string_resource ("textMode", "TextMode");
1133
if (s && !strcasecmp (s, "url")) p->tmode = TEXT_URL;
1134
else if (s && !strcasecmp (s, "literal")) p->tmode = TEXT_LITERAL;
1135
else if (s && !strcasecmp (s, "file")) p->tmode = TEXT_FILE;
1136
else if (s && !strcasecmp (s, "program")) p->tmode = TEXT_PROGRAM;
1137
else p->tmode = TEXT_DATE;
1073
1141
if (system_default_screenhack_count) /* note: first_time is also true */
1314
1393
format_hack (screenhack *hack, Bool wrap_p)
1317
int size = (2 * (strlen(hack->command) +
1318
(hack->visual ? strlen(hack->visual) : 0) +
1319
(hack->name ? strlen(hack->name) : 0) +
1321
char *h2 = (char *) malloc (size);
1400
char *def_name = make_hack_name (hack->command);
1402
/* Don't ever write out a name for a hack if it's the same as the default.
1404
if (hack->name && !strcmp (hack->name, def_name))
1411
size = (2 * (strlen(hack->command) +
1412
(hack->visual ? strlen(hack->visual) : 0) +
1413
(hack->name ? strlen(hack->name) : 0) +
1415
h2 = (char *) malloc (size);
1326
1418
if (!hack->enabled_p) *out++ = '-'; /* write disabled flag */
1328
1420
if (hack->visual && *hack->visual) /* write visual name */
1448
1542
if (p->screenhacks_count == 0)
1450
1544
free (p->screenhacks);
1451
1545
p->screenhacks = 0;
1550
/* Make sure all the values in the preferences struct are sane.
1553
stop_the_insanity (saver_preferences *p)
1555
if (p->passwd_timeout <= 0) p->passwd_timeout = 30000; /* 30 secs */
1556
if (p->timeout < 15000) p->timeout = 15000; /* 15 secs */
1557
if (p->cycle != 0 && p->cycle < 2000) p->cycle = 2000; /* 2 secs */
1558
if (p->pointer_timeout <= 0) p->pointer_timeout = 5000; /* 5 secs */
1559
if (p->notice_events_timeout <= 0)
1560
p->notice_events_timeout = 10000; /* 10 secs */
1561
if (p->fade_seconds <= 0 || p->fade_ticks <= 0)
1563
if (! p->fade_p) p->unfade_p = False;
1565
/* The DPMS settings may have the value 0.
1566
But if they are negative, or are a range less than 10 seconds,
1567
reset them to sensible defaults. (Since that must be a mistake.)
1569
if (p->dpms_standby != 0 &&
1570
p->dpms_standby < 10 * 1000)
1571
p->dpms_standby = 2 * 60 * 60 * 1000; /* 2 hours */
1572
if (p->dpms_suspend != 0 &&
1573
p->dpms_suspend < 10 * 1000)
1574
p->dpms_suspend = 2 * 60 * 60 * 1000; /* 2 hours */
1575
if (p->dpms_off != 0 &&
1576
p->dpms_off < 10 * 1000)
1577
p->dpms_off = 4 * 60 * 60 * 1000; /* 4 hours */
1579
/* standby may not be greater than suspend.
1580
suspend may not be greater than off.
1582
if (p->dpms_standby > p->dpms_suspend) p->dpms_standby = p->dpms_suspend;
1583
if (p->dpms_suspend > p->dpms_off) p->dpms_suspend = p->dpms_off;
1586
if (p->dpms_standby == 0 && /* if *all* are 0, then DPMS is disabled */
1587
p->dpms_suspend == 0 &&
1589
p->dpms_enabled_p = False;
1592
/* Watchdog timer set to 30s, anything else is too slow to react
1593
* appropriately on DPMS on battery running laptops (CPU intensive hack
1594
* keeps running for too long
1597
p->watchdog_timeout = 30000;
1598
/* p->watchdog_timeout = p->cycle * 0.6;
1601
if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000; /* 30 secs */
1602
if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /* 1 hr */
1604
if (p->pointer_hysteresis < 0) p->pointer_hysteresis = 0;
1605
if (p->pointer_hysteresis > 100) p->pointer_hysteresis = 100;