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
This commit is contained in:
@@ -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:
|
||||
```
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user