RSS block
This commit is contained in:
parent
c397cb79cc
commit
a149460074
|
@ -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
|
||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue