From 36758bee4f8a60ae1e9525135397cb23149a7a82 Mon Sep 17 00:00:00 2001 From: Yocraft-2000 <304616174+Yocraft-2000@users.noreply.github.com> Date: Sun, 19 Jul 2026 01:02:22 +0200 Subject: [PATCH] Web launcher plugin update (#47) * feat: refresh results when a favicon finishes downloading * fix: bump version * feat: add command setting * fix: fallback command if empty or not set --- web-launcher/README.md | 3 ++- web-launcher/launcher.luau | 20 +++++++++++++++----- web-launcher/plugin.toml | 10 +++++++++- web-launcher/translations/en.json | 4 ++++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/web-launcher/README.md b/web-launcher/README.md index 8c4db6d..f14d47d 100644 --- a/web-launcher/README.md +++ b/web-launcher/README.md @@ -12,7 +12,7 @@ Quickly open your favorite websites from the launcher. Favicons are downloaded a ## Requirements -A browser and `xdg-utils`. +A browser and `xdg-utils` (optional with advanced command setting). ## Usage @@ -27,6 +27,7 @@ You can customize the list and order of websites in settings. | `links` | `string_list` | `see below` | Websites list and order. | | `notify` | `bool` | `true` | Toggle notification when launching website. | | `icon_provider` | `select` | `google` | Icon download source. | +| `command` | `string` | `xdg-open` | Command that launches the website. | Default links: ``` diff --git a/web-launcher/launcher.luau b/web-launcher/launcher.luau index f0a0cb6..9a2d41f 100644 --- a/web-launcher/launcher.luau +++ b/web-launcher/launcher.luau @@ -72,8 +72,7 @@ local function downloadFavicon(domain, onDone) end) end -function onQuery(query) - local text = noctalia.string.trim(query) +local function makeResults(text, query) local results = {} for _, link in ipairs(links) do @@ -85,7 +84,9 @@ function onQuery(query) local iconValue = hasIcon and iconPath or nil if not hasIcon then - downloadFavicon(domain, function() end) + downloadFavicon(domain, function() + launcher.setResults(query, makeResults(text, query)) + end) end if text == "" then @@ -107,7 +108,12 @@ function onQuery(query) end end - launcher.setResults(query, results) + return results +end + +function onQuery(query) + local text = noctalia.string.trim(query) + launcher.setResults(query, makeResults(text, query)) end local function shellEscape(raw) @@ -115,7 +121,11 @@ local function shellEscape(raw) end function onActivate(id) - noctalia.runAsync("xdg-open " .. shellEscape(id)) + local command = noctalia.getConfig("command") + if not command or command == "" then + command = "xdg-open" + end + noctalia.runAsync(command .. " " .. shellEscape(id)) if noctalia.getConfig("notify") then noctalia.notify( diff --git a/web-launcher/plugin.toml b/web-launcher/plugin.toml index 9e84541..3ed156a 100644 --- a/web-launcher/plugin.toml +++ b/web-launcher/plugin.toml @@ -1,6 +1,6 @@ id = "yocraft/web-launcher" name = "Web Launcher" -version = "1.0.0" +version = "1.0.1" plugin_api = 3 author = "yocraft" license = "MIT" @@ -31,6 +31,14 @@ default = [ "Gmail|https://mail.google.com", ] +[[setting]] +key = "command" +type = "string" +label_key = "settings.command.label" +description_key = "settings.command.description" +default = "xdg-open" +advanced = true + [[setting]] key = "notify" type = "bool" diff --git a/web-launcher/translations/en.json b/web-launcher/translations/en.json index c3ce951..c7d1ae6 100644 --- a/web-launcher/translations/en.json +++ b/web-launcher/translations/en.json @@ -4,6 +4,10 @@ "label": "Links", "description": "Format: Name|https://url" }, + "command": { + "label": "Command", + "description": "Command that launches the website. Example: \"firefox --new-window\"" + }, "notify": { "label": "Notify", "description": "Notify when opening link."