summaryrefslogtreecommitdiffstats
path: root/.local/bin/ref-newsboat
blob: ca1aee15813c688139314c95b3f579cffca775fe (plain)
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
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env perl

use strict;
use warnings;
use Capture::Tiny qw(capture);

use constant {
	NEWSBOAT_PATH		=> 'newsboat',
	NOTIFY_SEND_PATH	=> 'notify-send'
};

sub main
{
	my $stdout;
	my $nb;

	$nb = NEWSBOAT_PATH;
	if (system(
		$nb,
		'-x',
		'reload'
	) != 0) {
		exit 1;
	}

	$stdout = qx($nb -x print-unread);
	$stdout =~ s/\s.+//;
	chomp $stdout;
	if ($stdout != 0) {
		system(
			NOTIFY_SEND_PATH,
			'-u',
			'low',
			'-t',
			'4000',
			'newsboat',
			'  <b>' . $stdout . '</b> new articles'
		);
	}
	return;
}

main();

__END__