Skip to content
Merged
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
35 changes: 20 additions & 15 deletions shelly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,41 @@ Shelly is a plugin that uses the [Shelly Arch Package Manager](https://github.co

## Plugin

| Field | Value |
| ------- | --------------------------------------- |
| ID | `joshuaslate/shelly` |
| Field | Value |
| ------- | ---------------------------------------------- |
| ID | `joshuaslate/shelly` |
| Entries | Service: `update_poller`; bar widget: `shelly` |

## Requirements

Install the Shelly Arch Package Manager from the [AUR](https://aur.archlinux.org/packages/shelly). The `shelly`
Install the Shelly Arch Package Manager (>= v3.0.0) from the [AUR](https://aur.archlinux.org/packages/shelly). The `shelly`
command must be available on `PATH`.

Test that it works by running `shelly check-updates` in a terminal. If it returns a list of packages, then it is working correctly.
Verify the correct version is installed by running `shelly --version` in a terminal. It should return a version number >= 3.0.0.

Test that it works by running `shelly list updates all` in a terminal. If it returns a list of packages, then it is working correctly.

## Usage

Add the `shelly` widget from Noctalia's widget picker. It periodically checks
for available Arch package updates and shows their count and names in the bar
tooltip. Click behavior is configurable: open Shelly's graphical interface,
run `shelly upgrade-all` in a terminal, or do nothing.
run `shelly upgrade all` in a terminal, or do nothing.

The `update_poller` service owns the periodic checks and can notify you when
new updates become available.

## Settings

| Setting | Type | Default | Description |
| ---------------------- | -------- | ------------ | -------------------------------------------------------------------------------------------------- |
| `interval` | `int` | `300` | The interval (in seconds) between update checks |
| `notify` | `bool` | `false` | Whether or not you want to receive notifications when there are new package updates available |
| `color` | `color` | `on_surface` | The text color for the bar widget |
| `glyph_color` | `color` | `on_surface` | The color of the glyph on the bar widget |
| `glyph` | `glyph` | `package` | Bar widget icon. |
| `click_action` | `select` | `open_gui` | The action to perform when the bar widget is clicked. Options: `open_gui`, `open_updater`, `none`. |
| `hide_when_up_to_date` | `bool` | `false` | Whether or not to hide the bar widget when there are no package updates available |
| Setting | Type | Default | Description |
| ---------------------- | -------- | ----------------- | -------------------------------------------------------------------------------------------------------- |
| `interval` | `int` | `300` | The interval (in seconds) between update checks |
| `notify` | `bool` | `false` | Whether or not you want to receive notifications when there are new package updates available |
| `color` | `color` | `on_surface` | The text color for the bar widget |
| `bar_label` | `select` | `count_and_label` | The label to display in the bar widget when there are updates. Options: `count_only`, `count_and_label`. |
| `bar_font_size` | `int` | `14` | The size of the font displayed in the bar widget |
| `glyph_color` | `color` | `on_surface` | The color of the glyph on the bar widget |
| `glyph` | `glyph` | `package` | Bar widget icon |
| `glyph_size` | `int` | `14` | The size of the glyph in the bar widget |
| `click_action` | `select` | `open_gui` | The action to perform when the bar widget is clicked. Options: `open_gui`, `open_updater`, `none`. |
| `hide_when_up_to_date` | `bool` | `false` | Whether or not to hide the bar widget when there are no package updates available |
27 changes: 26 additions & 1 deletion shelly/plugin.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id = "joshuaslate/shelly"
name = "Shelly"
icon = "package"
version = "1.0.1"
version = "2.0.0"
plugin_api = 3
license = "MIT"
author = "joshuaslate"
Expand Down Expand Up @@ -47,6 +47,24 @@ entry = "widget.luau"
description_key = "settings.color.description"
default = "on_surface"

[[widget.setting]]
key = "bar_label"
type = "select"
label_key = "settings.bar_label.label"
description_key = "settings.bar_label.description"
default = "count_and_label"
options = [
{ value = "count_and_label", label_key = "settings.bar_label.options.count_and_label" },
{ value = "count_only", label_key = "settings.bar_label.options.count_only" }
]

[[widget.setting]]
key = "bar_font_size"
type = "int"
label_key = "settings.bar_font_size.label"
description_key = "settings.bar_font_size.description"
default = 14

[[widget.setting]]
key = "glyph"
type = "glyph"
Expand All @@ -61,6 +79,13 @@ entry = "widget.luau"
description_key = "settings.glyph_color.description"
default = "on_surface"

[[widget.setting]]
key = "glyph_size"
type = "int"
label_key = "settings.glyph_size.label"
description_key = "settings.glyph_size.description"
default = 14

[[widget.setting]]
key = "click_action"
type = "select"
Expand Down
11 changes: 9 additions & 2 deletions shelly/poller.luau
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ noctalia.setUpdateInterval(updateInterval)
function refresh()
isPolling = true

noctalia.runAsync("shelly check-updates --json", function(result)
noctalia.runAsync("shelly list-updates all --json", function(result)
isPolling = false

if result.exitCode ~= 0 then
Expand All @@ -28,7 +28,14 @@ function refresh()
return
end

local decoded = noctalia.json.decode(result.stdout)
local stdout = result.stdout

-- Shelly's JSON output may leak stderr into stdout. Remove stderr value to ensure valid JSON.
if result.stderr ~= "" then
stdout = stdout:gsub(result.stderr, "")
end

local decoded = noctalia.json.decode(stdout)
if type(decoded) ~= "table" then
updateError = noctalia.tr("bar.tooltip.error.decode_json")
noctalia.state.set("update_error", updateError)
Expand Down
18 changes: 17 additions & 1 deletion shelly/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"tooltip": {
"aur_title": "AUR",
"error": {
"decode_json": "Failed to decode output from `shelly check-updates --json`"
"decode_json": "Failed to decode output from `shelly list-updates all --json`"
},
"flatpak_title": "Flatpak",
"no_updates": "System is up to date",
Expand All @@ -30,6 +30,18 @@
}
},
"settings": {
"bar_font_size": {
"description": "The font size of the bar text.",
"label": "Bar Font Size"
},
"bar_label": {
"description": "Label to display in the bar.",
"label": "Bar Label",
"options": {
"count_only": "Count Only (e.g., 5)",
"count_and_label": "Count and Label (e.g., 5 Updates)"
}
},
"click_action": {
"description": "What happens when you click on the bar.",
"label": "Click Action",
Expand All @@ -51,6 +63,10 @@
"description": "The color of the glyph.",
"label": "Glyph Color"
},
"glyph_size": {
"description": "The size of the glyph.",
"label": "Glyph Size"
},
"hide_when_up_to_date": {
"description": "Whether to hide the bar when there are no updates available.",
"label": "Hide When Up-to-Date"
Expand Down
9 changes: 6 additions & 3 deletions shelly/widget.luau
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
local glyph = noctalia.getConfig("glyph")
local color = noctalia.getConfig("color") or "on_surface"
local glyphColor = noctalia.getConfig("glyph_color") or color
local glyphSize = noctalia.getConfig("glyph_size") or 14
local updateError = noctalia.state.get("update_error")
local notifyOnNewUpdates = noctalia.getConfig("notify")
local hideWhenUpToDate = noctalia.getConfig("hide_when_up_to_date")
local click_action = noctalia.getConfig("click_action") or "open_gui"
local barLabelType = noctalia.getConfig("bar_label") or "count_and_label"
local barFontSize = noctalia.getConfig("bar_font_size") or 14
local updates = noctalia.state.get("updates") or { Packages = {}, Aur = {}, Flatpak = {} }

local function countUpdates(scopedUpdates)
Expand Down Expand Up @@ -71,8 +74,8 @@ local function render()
local count = countUpdates(updates)

barWidget.render(container({ gap = 6, align = "center", visible = not hideWhenUpToDate or count > 0 }, {
ui.glyph({ name = glyph, size = 14, color = glyphColor, visible = glyph ~= "" }),
ui.label({ text = noctalia.trp("bar.text.updates", count), color = color }),
ui.glyph({ name = glyph, size = glyphSize, color = glyphColor, visible = glyph ~= "" }),
ui.label({ text = barLabelType == "count_only" and string.format("%d", count) or noctalia.trp("bar.text.updates", count), color = color, fontSize = barFontSize }),
}))

updateTooltip(count)
Expand Down Expand Up @@ -109,7 +112,7 @@ function onClick()
return
end

noctalia.runInTerminal(cmd .. " upgrade-all")
noctalia.runInTerminal(cmd .. " upgrade all")
end
end

Expand Down