I'm in the process of getting my icewm window manager set up for my liking, and I came upon a problem with putting 'ps' in the icewm menu. The problem it seems, is that if you start an xterm and -e ps, the xterm will close upon completion of ps. I tried a few tricks like -e a bash shell first, but to no avail, so I decided this might be a good job for Tk. It includes a left-click update, and a right-click close, for quick operation. Plus, with wrapping turned off, you can scroll right and see the family trees.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use IPC::Open3;
$|=1;
my $pid = open3(\*IN,\*OUT,0,'/bin/sh');
my $mw = new MainWindow(-title=>'Left Click->Update Right Click->Clo
+se');
$mw->fontCreate('medium',
-family=>'courier',
-weight=>'bold',
-size=>int(-14*14/10));
my $text = $mw->Scrolled('Text',
-bg => 'black',
-fg => 'lightsteelblue',
-width => 130,
-height => 30,
-font => 'medium',
-wrap => 'none'
)->pack;
$mw->fileevent(\*OUT,'readable',\&get_from);
$mw->bind('<ButtonPress-1>' => sub{
$text->delete('1.0','end');
$text->update;
print IN "ps auxww --forest\n";
});
$mw->bind('<ButtonPress-3>' => sub{ exit });
print IN "ps auxww --forest\n";
MainLoop;
sub get_from {
my $pstext = (<OUT>);
$text->insert('end',$pstext);
$text->see('1.0');
}
__END__