Add nightwatch75/file-search 0.0.9 — fuzzy file search (bar widget + panel + launcher provider) (#26)
* Add nightwatch75/file-search 0.0.7 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * file-search: backtick dependency names in Requirements (CI check) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * file-search 0.0.8: address review — safe index records, atomic cache writes, command dependencies, index fingerprint Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * file-search 0.0.8: min_noctalia → plugin_api = 3 (manifest format change) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * file-search 0.0.9: move index to noctalia.pluginDataDir() Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Massimiliano <m.angei@iotron.it> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: nightwatch75 <nightwatch75@users.noreply.github.com>
This commit is contained in:
co-authored by
Massimiliano
Claude Fable 5
nightwatch75
parent
da237fe43b
commit
c71ec00354
@@ -0,0 +1,70 @@
|
||||
--!nonstrict
|
||||
-- file-search — bar widget that toggles the fuzzy search panel.
|
||||
--
|
||||
-- The panel (panel.luau) publishes its open state on the shared
|
||||
-- "file_search_open" state key; the glyph lights up while it is open.
|
||||
--
|
||||
-- Click mapping:
|
||||
-- Left click — open/close the search panel
|
||||
-- Right click — open the search folder in the file manager
|
||||
-- Middle click — copy the search folder path to the clipboard
|
||||
|
||||
local PANEL_ID = "nightwatch75/file-search:panel"
|
||||
|
||||
local open = false
|
||||
|
||||
local function shellQuote(value)
|
||||
return "'" .. value:gsub("'", "'\\''") .. "'"
|
||||
end
|
||||
|
||||
local function searchRoot()
|
||||
local dir = noctalia.getConfig("search_folder")
|
||||
if dir == nil or dir == "" then
|
||||
dir = noctalia.getenv("HOME") or "/tmp"
|
||||
else
|
||||
dir = noctalia.expandPath(dir)
|
||||
end
|
||||
dir = dir:gsub("/+$", "")
|
||||
if dir == "" then
|
||||
dir = "/"
|
||||
end
|
||||
return dir
|
||||
end
|
||||
|
||||
local function render()
|
||||
barWidget.setGlyph(noctalia.getConfig("glyph"))
|
||||
local root = searchRoot()
|
||||
if open then
|
||||
barWidget.setGlyphColor("primary")
|
||||
barWidget.setTooltip(noctalia.tr("tooltip_open", { path = root }))
|
||||
else
|
||||
barWidget.setGlyphColor("on_surface")
|
||||
barWidget.setTooltip(noctalia.tr("tooltip_closed", { path = root }))
|
||||
end
|
||||
end
|
||||
|
||||
noctalia.state.watch("file_search_open", function(value)
|
||||
open = value == true
|
||||
render()
|
||||
end)
|
||||
|
||||
-- Periodic re-render keeps the glyph and tooltip in sync with settings changes.
|
||||
function update()
|
||||
render()
|
||||
end
|
||||
|
||||
function onClick()
|
||||
noctalia.togglePanel(PANEL_ID)
|
||||
end
|
||||
|
||||
function onRightClick()
|
||||
noctalia.runAsync("xdg-open " .. shellQuote(searchRoot()) .. " >/dev/null 2>&1")
|
||||
end
|
||||
|
||||
function onMiddleClick()
|
||||
noctalia.copyToClipboard(searchRoot(), "text/plain")
|
||||
noctalia.notify(noctalia.tr("title"), noctalia.tr("copied_path"))
|
||||
end
|
||||
|
||||
noctalia.setUpdateInterval(1000)
|
||||
render()
|
||||
Reference in New Issue
Block a user