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__
In reply to tk-ps
by zentara
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.