File: arch-run-demo-2

package info (click to toggle)
libarch-perl 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 576 kB
  • ctags: 430
  • sloc: perl: 6,145; makefile: 31
file content (35 lines) | stat: -rwxr-xr-x 911 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../perllib";

use Gtk2 -init;
use Glib qw(TRUE FALSE);
use Arch::Run qw(poll run_async LINES);

# use "/usr/share/doc/*" on slow disks
my @dirs = @ARGV ? @ARGV : glob('/usr/share/*');

my $window = Gtk2::Window->new;
my $label = Gtk2::Label->new("no du output yet");
my $pbar = Gtk2::ProgressBar->new;
my $vbox = Gtk2::VBox->new;
$vbox->add($label); $vbox->add($pbar); $window->add($vbox);
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->set_default_size(200, 48); $window->show_all;
sub set_str { $label->set_text($_[0]); }

my $keep = 1;
Glib::Timeout->add(100, sub { $pbar->pulse; poll(0); $keep; });

run_async(
	command => [ 'du', '-hs', @dirs ],
	mode    => LINES,
	datacb  => sub { chomp(my $str = $_[0]); set_str($str); },
	exitcb  => sub { $keep = 0; set_str("exit code: $_[0]"); },
);

Gtk2->main;