Xref: utzoo comp.windows.x:20150 comp.sources.wanted:11113 alt.sources:1643 comp.lang.perl:867 Path: utzoo!attcan!uunet!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.windows.x,comp.sources.wanted,alt.sources,comp.lang.perl Subject: Re: Xfortune? Message-ID: <100809@convex.convex.com> Date: 23 Mar 90 11:39:23 GMT References: Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Followup-To: comp.windows.x Organization: CONVEX Software Development, Richardson, TX Lines: 51 In article 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 () { $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 : Editor too big!"