summaryrefslogtreecommitdiffstats
path: root/.local/bin/ref-newsboat.pl
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-18 22:47:00 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-18 22:47:00 +0200
commite1d747f2568b720b2479201b94e8b118261f258f (patch)
treec9dbaff68e0ed16c91b7dab141f9a1faa7e9cfbb /.local/bin/ref-newsboat.pl
parentUpdate (diff)
downloaddotfiles-bsd-e1d747f2568b720b2479201b94e8b118261f258f.tar.gz
dotfiles-bsd-e1d747f2568b720b2479201b94e8b118261f258f.tar.bz2
dotfiles-bsd-e1d747f2568b720b2479201b94e8b118261f258f.tar.xz
dotfiles-bsd-e1d747f2568b720b2479201b94e8b118261f258f.tar.zst
dotfiles-bsd-e1d747f2568b720b2479201b94e8b118261f258f.zip
Scripts
Diffstat (limited to '.local/bin/ref-newsboat.pl')
-rwxr-xr-x.local/bin/ref-newsboat.pl45
1 files changed, 45 insertions, 0 deletions
diff --git a/.local/bin/ref-newsboat.pl b/.local/bin/ref-newsboat.pl
new file mode 100755
index 0000000..70e2955
--- /dev/null
+++ b/.local/bin/ref-newsboat.pl
@@ -0,0 +1,45 @@
+#!/usr/local/bin/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__