Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions rss-notifier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# RSS Utils

Plugin para Noctalia que monitora feeds RSS e exibe notificações quando novos itens são encontrados.

---

## Installation

1. Clone este repositório para o diretório de plugins do Noctalia:

git clone https://github.com/nilsonlinux/rss-notifier.git ~/.config/noctalia/plugins/rss-notifier
text

2. Reinicie o Noctalia ou recarregue os plugins.

---

## Plugin

**Manifest ID:** `nilsonlinux/rss-notifier`

Este plugin fornece os seguintes componentes:

### Widget: `badge`
Um widget que exibe um emblema (badge) na barra lateral ou painel com a contagem de itens não lidos dos feeds monitorados.

### Panel: `list`
Um painel que exibe uma lista detalhada de todos os itens de RSS coletados. Pode ser aberto através do comando IPC.

### Service: `fetcher`
Serviço em background responsável por buscar e atualizar os feeds RSS no intervalo de tempo configurado.

---

## Settings

As seguintes opções de configuração estão disponíveis para o plugin:

| Opção | Tipo | Padrão | Descrição |
| :--- | :--- | :--- | :--- |
| **feeds** | `array` | `[]` | Lista de URLs de feeds RSS/Atom para monitorar. |
| **refresh_interval** | `integer` | `30` | Intervalo em minutos para verificar novos itens. |
| **notify_new_items** | `boolean` | `true` | Exibe uma notificação no sistema quando novos itens são encontrados. |
| **max_items_per_feed** | `integer` | `10` | Número máximo de itens recentes mantidos em cache por feed. |

---

## Usage

### Abrindo o Painel
Para abrir ou fechar o painel com a lista de itens do RSS Utils, utilize o seguinte comando na barra de comandos do Noctalia:

noctalia msg panel-toggle nilsonlinux/rss-notifier:list
text


### Funcionamento Básico
1. Após adicionar as URLs dos feeds nas **Configurações**, o serviço `fetcher` verificará automaticamente por novidades no intervalo definido.
2. Quando novos itens são detectados, uma notificação será exibida (se habilitado) e o widget `badge` será atualizado.
3. Ao abrir o painel através do comando acima, você poderá visualizar a lista de itens.

---

## Dependencies

- [Noctalia](https://github.com/noctalia/noctalia) (versão mais recente)
- Acesso à internet para buscar os feeds RSS.

---

## License

MIT
81 changes: 81 additions & 0 deletions rss-notifier/panel.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
-- panel.luau
-- Janela pop-up mostrada ao clicar no widget da barra: lista os itens mais
-- recentes, ou um estado vazio com icone quando nao ha nada novo.

local items = {}

local function openLink(link)
if not link or link == "" then
return
end
-- escapa aspas simples pra evitar quebrar o comando do shell
local safe = link:gsub("'", "'\\''")
noctalia.runAsync("xdg-open '" .. safe .. "'")
end

local function itemRow(item)
return ui.column({
key = item.id or item.link or item.title,
gap = 2,
padding = 10,
radius = 8,
fill = "surface_variant/0.4",
onClick = function() openLink(item.link) end,
}, {
ui.label({ text = item.title or "(sem titulo)", fontWeight = "bold", maxLines = 2 }),
ui.label({ text = item.feedTitle or "", fontSize = 12, color = "outline" }),
})
end

local function emptyState()
return ui.column({ gap = 10, align = "center", padding = 32, flexGrow = 1, justify = "center" }, {
ui.glyph({ name = "rss", size = 32, color = "outline" }),
ui.label({ text = "Nenhuma atualização", color = "outline" }),
})
end

local function render()
local body

if #items == 0 then
body = emptyState()
else
local rows = {}
for _, item in ipairs(items) do
table.insert(rows, itemRow(item))
end
body = ui.scroll({ gap = 6, flexGrow = 1 }, rows)
end

panel.render(ui.column({ gap = 10, padding = 12, fill = true }, {
ui.row({ align = "center", justify = "space_between" }, {
ui.label({ text = "RSS/Atom Notifier", fontSize = 15, fontWeight = "bold" }),
ui.row({ gap = 4 }, {
ui.button({ glyph = "refresh", variant = "ghost", controlSize = "sm", tooltip = "Atualizar agora", onClick = "onRefreshClicked" }),
ui.button({ glyph = "close", variant = "ghost", controlSize = "sm", onClick = "onCloseClicked" }),
}),
}),
ui.separator({}),
body,
}))
end

noctalia.state.watch("items", function(raw)
local ok, decoded = pcall(noctalia.json.decode, raw or "[]")
items = (ok and decoded) or {}
render()
end)

function onOpen(_context)
render()
-- abrir o painel conta como "li as novidades": zera o badge no service
noctalia.runAsync("noctalia msg plugin nilsonlinux/rss-notifier:fetcher all mark-read")
end

function onRefreshClicked()
noctalia.runAsync("noctalia msg plugin nilsonlinux/rss-notifier:fetcher all refresh")
end

function onCloseClicked()
panel.close()
end
60 changes: 60 additions & 0 deletions rss-notifier/plugin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
id = "nilsonlinux/rss-notifier"
name = "RSS/Atom Notifier"
version = "1.0.0"
plugin_api = 14
author = "Nilsonlinux"
license = "MIT"
icon = "rss"
description = "Acompanha feeds RSS/Atom e notifica quando surgem novos itens."
tags = ["utility"]
dependencies = []

[[setting]]
key = "feed_urls"
type = "string_list"
label_key = "settings.feed_urls.label"
description_key = "settings.feed_urls.description"
default = []

[[setting]]
key = "refresh_minutes"
type = "int"
label_key = "settings.refresh_minutes.label"
description_key = "settings.refresh_minutes.description"
default = 30
min = 1
max = 1440

[[setting]]
key = "notify_new"
type = "bool"
label_key = "settings.notify_new.label"
description_key = "settings.notify_new.description"
default = true

[[setting]]
key = "max_notifications_per_cycle"
type = "int"
label_key = "settings.max_notifications_per_cycle.label"
description_key = "settings.max_notifications_per_cycle.description"
default = 5
min = 1
max = 50
advanced = true

[[service]]
id = "fetcher"
entry = "service.luau"

[[widget]]
id = "badge"
entry = "widget.luau"

[[panel]]
id = "list"
entry = "panel.luau"
width = 360
height = 440
placement = "attached"
position = "auto"
open_near_click = true
Loading