summaryrefslogtreecommitdiffstats
path: root/.local/bin/ref-newsboat
blob: 090ca635db87d135b063454889ba685b968bb7bb (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		=> '/usr/local/bin/newsboat',
	NOTIFY_SEND_PATH	=> '/usr/local/bin/notify-send'
};

sub main
{
	my $stdout;
	if (system(
		NEWSBOAT_PATH,
		'-x',
		'reload'
	) != 0) {
		exit 1;
	}
	($stdout, undef, undef) = capture {
		system(
			NEWSBOAT_PATH,
			'-x',
			'print-unread'
		);
	};
	$stdout =~ s/\s.+//;
	chomp $stdout;
	if ($stdout != 0) {
		system(
			NOTIFY_SEND_PATH,
			'-u',
			'low',
			'newsboat',
			'  ' . $stdout . ' new articles'
		);
	}
	exit 0;
}

main();

__END__