RSS block

This commit is contained in:
Simon Vieille 2017-12-04 18:17:42 +01:00
parent c397cb79cc
commit a149460074
No known key found for this signature in database
GPG Key ID: 919533E2B946EA10
2 changed files with 35 additions and 0 deletions

View File

@ -79,6 +79,12 @@ command=/home/simon/.i3/bar/src/date.php
format=json
interval=30
[ttr_news]
command=/home/simon/.i3/bar/src/rss.php "https://tiny.deblan.org/public.php?op=rss&id=-3&key=17c659af1ad27f30941a724fcf48421d1e83081a" "RSS"
min_width=button=1
align=left
interval=30
[acpi]
command=/home/simon/.i3/bar/src/acpi.php
format=json

29
bar/src/rss.php Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/php
<?php
require __DIR__.'/base/block.php';
$rss = $argv[1] ?? null;
$title = $argv[2] ?? null;
if (empty($rss) || empty($title)) {
die;
}
$content = @file_get_contents($rss);
if (empty($content)) {
die;
}
preg_match_all('/<entry/isU', $content, $matches, PREG_SET_ORDER);
$fullText = sprintf('[%s] %s', $title, count($matches));
$blockButton = (int) getenv('BLOCK_BUTTON');
if ($blockButton === 1) {
shell_exec('xdg-open https://tiny.deblan.org/index.php');
}
echo $fullText;