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
|
## Requirements
|
||||||
|
|
||||||
A browser and `xdg-utils`.
|
A browser and `xdg-utils` (optional with advanced command setting).
|
||||||
|
|
||||||
## Usage
|
## 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. |
|
| `links` | `string_list` | `see below` | Websites list and order. |
|
||||||
| `notify` | `bool` | `true` | Toggle notification when launching website. |
|
| `notify` | `bool` | `true` | Toggle notification when launching website. |
|
||||||
| `icon_provider` | `select` | `google` | Icon download source. |
|
| `icon_provider` | `select` | `google` | Icon download source. |
|
||||||
|
| `command` | `string` | `xdg-open` | Command that launches the website. |
|
||||||
|
|
||||||
Default links:
|
Default links:
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ local function downloadFavicon(domain, onDone)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function onQuery(query)
|
local function makeResults(text, query)
|
||||||
local text = noctalia.string.trim(query)
|
|
||||||
local results = {}
|
local results = {}
|
||||||
|
|
||||||
for _, link in ipairs(links) do
|
for _, link in ipairs(links) do
|
||||||
@@ -85,7 +84,9 @@ function onQuery(query)
|
|||||||
local iconValue = hasIcon and iconPath or nil
|
local iconValue = hasIcon and iconPath or nil
|
||||||
|
|
||||||
if not hasIcon then
|
if not hasIcon then
|
||||||
downloadFavicon(domain, function() end)
|
downloadFavicon(domain, function()
|
||||||
|
launcher.setResults(query, makeResults(text, query))
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if text == "" then
|
if text == "" then
|
||||||
@@ -107,7 +108,12 @@ function onQuery(query)
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
local function shellEscape(raw)
|
local function shellEscape(raw)
|
||||||
@@ -115,7 +121,11 @@ local function shellEscape(raw)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onActivate(id)
|
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
|
if noctalia.getConfig("notify") then
|
||||||
noctalia.notify(
|
noctalia.notify(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
id = "yocraft/web-launcher"
|
id = "yocraft/web-launcher"
|
||||||
name = "Web Launcher"
|
name = "Web Launcher"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
plugin_api = 3
|
plugin_api = 3
|
||||||
author = "yocraft"
|
author = "yocraft"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -31,6 +31,14 @@ default = [
|
|||||||
"Gmail|https://mail.google.com",
|
"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]]
|
[[setting]]
|
||||||
key = "notify"
|
key = "notify"
|
||||||
type = "bool"
|
type = "bool"
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
"label": "Links",
|
"label": "Links",
|
||||||
"description": "Format: Name|https://url"
|
"description": "Format: Name|https://url"
|
||||||
},
|
},
|
||||||
|
"command": {
|
||||||
|
"label": "Command",
|
||||||
|
"description": "Command that launches the website. Example: \"firefox --new-window\""
|
||||||
|
},
|
||||||
"notify": {
|
"notify": {
|
||||||
"label": "Notify",
|
"label": "Notify",
|
||||||
"description": "Notify when opening link."
|
"description": "Notify when opening link."
|
||||||
|
|||||||
Reference in New Issue
Block a user