X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver-text;h=1f411851070f56173c581398397d038482f9293e;hb=ec8d2b32b63649e6d32bdfb306eda062769af823;hp=6c0b63d48d23a749923e0fa937328c5300201d48;hpb=5f1f12f2a37da634000f96d18d59cc73a8814ef7;p=xscreensaver diff --git a/driver/xscreensaver-text b/driver/xscreensaver-text index 6c0b63d4..1f411851 100755 --- a/driver/xscreensaver-text +++ b/driver/xscreensaver-text @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2005-2010 Jamie Zawinski +# Copyright © 2005-2011 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -30,7 +30,7 @@ use Text::Wrap qw(wrap); use bytes; my $progname = $0; $progname =~ s@.*/@@g; -my $version = q{ $Revision: 1.21 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; +my $version = q{ $Revision: 1.24 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; my $verbose = 0; my $http_proxy = undef; @@ -247,6 +247,7 @@ sub get_cocoa_prefs($) { elsif ($text_mode eq '1') { $text_mode = 'literal'; } elsif ($text_mode eq '2') { $text_mode = 'file'; } elsif ($text_mode eq '3') { $text_mode = 'url'; } + elsif ($text_mode eq '4') { $text_mode = 'program'; } $v = get_cocoa_pref_1 ($id, "textLiteral"); $text_literal = $v if defined ($v); @@ -384,12 +385,14 @@ sub output() { } else { # $text_mode eq 'date' - safe_system ("uname", "-n"); + my $n = `uname -n`; + $n =~ s/\.local\n/\n/s; + print $n; my $unamep = 1; if (-f "/etc/redhat-release") { # "Fedora Core release 4 (Stentz)" - system ("cat", "/etc/redhat-release"); + safe_system ("cat", "/etc/redhat-release"); } if (-f "/etc/release") { # "Solaris 10 3/05 s10_74L2a X86" @@ -400,8 +403,8 @@ sub output() { my $sp = # "iMac G5" `/usr/sbin/system_profiler SPSoftwareDataType SPHardwareDataType`; my ($v) = ($sp =~ m/^\s*System Version:\s*(.*)$/mi); - my ($s) = ($sp =~ m/^\s*CPU Speed:\s*(.*)$/mi); - my ($t) = ($sp =~ m/^\s*Machine Name:\s*(.*)$/mi); + my ($s) = ($sp =~ m/^\s*(?:CPU|Processor) Speed:\s*(.*)$/mi); + my ($t) = ($sp =~ m/^\s*(?:Machine|Model) Name:\s*(.*)$/mi); print "$v\n" if ($v); print "$s $t\n" if ($s && $t); $unamep = !defined ($v); @@ -900,6 +903,42 @@ sub main() { } output(); + + + if (defined ($cocoa_id)) { + # + # On MacOS, sleep for 10 seconds between when the last output is + # printed, and when this process exits. This is because MacOS + # 10.5.0 and later broke ptys in a new and exciting way: basically, + # once the process at the end of the pty exits, you have exactly + # 1 second to read all the queued data off the pipe before it is + # summarily flushed. + # + # Many of the screen savers were written to depend on being able + # to read a small number of bytes, and continue reading until they + # reached EOF. This is no longer possible. + # + # Note that the current MacOS behavior has all four of these + # awesome properties: 1) Inconvenient; 2) Has no sane workaround; + # 3) Different behavior than MacOS 10.1 through 10.4; and 4) + # Different behavior than every other Unix in the world. + # + # See http://jwz.livejournal.com/817438.html, and for those of + # you inside Apple, "Problem ID 5606018". + # + # One workaround would be to rewrite the savers to have an + # internal buffer, and always read as much data as possible as + # soon as a pipe has input available. However, that's a lot more + # work, so instead, let's just not exit right away, and hope that + # 10 seconds is enough. + # + # This will solve the problem for invocations of xscreensaver-text + # that produce little output (e.g., date-mode); and won't solve it + # in cases where a large amount of text is generated in a short + # amount of time (e.g., url-mode.) + # + sleep (10); + } } main();