[alt.sources] Xfortune?

tchrist@convex.COM (Tom Christiansen) (03/23/90)

In article <JV.90Mar21094521@squirrel.mh.nl> jv@mh.nl (Johan Vromans) writes:
>I'm looking for a X version of fortune(6). One that displays the
>fortune message in a separate window, sized to the size of the
>message.
>Does there exist such a goodie?
>
>Thanks for any info.
>
>	Johan

There does now. :-)  Actually, it's not a "real" x program, but it's
good enough for me.  We just snarf in a fortune, take its measurements, 
and call up an xterm with the right dimensions.    Clip and call
"xfortune", and pass it fortune arguments, like -l and -a.


    #!/usr/bin/perl

    ($me = $0) =~ s,.*/,,;

    $FORTUNE = '/usr/games/fortune';
    $TMP = "/tmp/$me.$$";

    die "can't run $FORTUNE: $!" unless -x $FORTUNE;

    open (FORTUNE, "$FORTUNE @ARGV | expand |");
    while (<FORTUNE>) {
	$rows++;
	$cols = length if $cols < length;
	$fortune .= $_;
    } 
    (close FORTUNE) || die "bad pclose on $FORTUNE: $?";

    $rows++, $cols++;

    open (TMP, ">$TMP") || die "can't write $TMP: $!";
    print TMP $fortune;
    close TMP;

    system 'xterm', '-geometry', "${cols}x${rows}", 
	    '-n', 'xfort', 
	    '-e', 'less', '-P(hit q to quit)', $TMP;

    unlink $TMP;

--tom
--

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"