Files
community-plugins/udiskie/status.luau
T
Arístides PérezandGitHub 57e4b108c4 feat(udiskie): add aristides/udiskie plugin for usb/media drives management (#256)
* feat(udiskie): add Udiskie service for real-time device monitoring, notifications, and IPC

* feat(udiskie): add main manager panel for drives and partitions

* feat(udiskie): add plugin manifest, status widget, and english translation

* feat(udiskie): add Makefile for testing and linting translations

* feat(udiskie): add error handling for missing udiskie package

* feat(udiskie): add right-click functionality to refresh Udiskie service

* feat(udiskie): add option to hide widget when no devices are connected

* feat(udiskie): add settings button to the panel for quick access to configuration

* feat(udiskie): add button to copy mount path to clipboard in partition row

* fix(udiskie): duplicated notifications when removing or unmounting devices

* feat(udiskie): add disk usage information for mounted partitions in device state

* feat(udiskie): update partition row status colors and enhance UI for status display

* fix(udiskie): adjust timeout to give time for sudo tasks such as LUKS unlock

* feat(udiskie): update partition row status color for LUKS devices and adjust panel width

* fix(udiskie): scroll not working properly and items overflow container

* feat(udiskie): add missing translations and remove hardcoded strings messages

* feat(udiskie): add README and thumbnail

* docs(udiskie): add performance section to README with resource usage comparison

* fix(udiskie): update output parsing to use safe tab delimiters for device information

* fix(udiskie): improve device hierarchy parsing to correctly identify partitions

* feat(udiskie): centralize open with file manager code, and close panel on auto-open on mount (like manually open)

* fix(udiskie): exclude LUKS containers from "Drive Connected" notifications

* fix(udiskie): quote paths and device names in shell commands

* fix(udiskie): improve error message cleaning regex

* feat(udiskie): enhance README with device attributes and update service to suppress errors

* fix(udiskie): use shell quoting for device paths in panel async commands

* feat(udiskie): add spanish translations and update tests to check every translation
2026-08-05 17:58:15 -04:00

80 lines
2.2 KiB
Luau

--!nonstrict
-- Udiskie bar widget: renders the mounted-device count and a tooltip listing.
-- the mounted devices. State comes from the udiskie service via shared state.
local function mountedDevices(data)
if type(data) ~= "table" or type(data.raw) ~= "table" then
return {}
end
local out = {}
for _, d in ipairs(data.raw) do
if d.mounted then
table.insert(out, d)
end
end
return out
end
local function render()
local data = noctalia.state.get("udiskie_devices")
local mounted = mountedDevices(data)
local glyph = noctalia.getConfig("glyph") or "device-usb"
local showCount = noctalia.getConfig("show_count")
barWidget.setGlyph(glyph)
if type(data) == "table" and data.error then
barWidget.setGlyphColor("#f59e0b")
barWidget.setText("")
barWidget.setTooltip(noctalia.tr("error_missing_dep"))
return
else
-- Reset to the theme default. The API does not document "" as a reset;
-- today it clears the role/color. Revisit if the host ever rejects it.
barWidget.setGlyphColor("")
barWidget.setColor("")
end
local hideWhenEmpty = noctalia.getConfig("hide_when_empty") == true
local rawCount = (type(data) == "table" and type(data.raw) == "table") and #data.raw or 0
if hideWhenEmpty and rawCount == 0 then
barWidget.setVisible(false)
return
else
barWidget.setVisible(true)
end
if #mounted == 0 then
barWidget.setText("")
barWidget.setTooltip(noctalia.tr("tooltip_empty"))
return
end
if showCount == nil or showCount == true then
barWidget.setText(tostring(#mounted))
else
barWidget.setText("")
end
local rows = {}
for _, d in ipairs(mounted) do
table.insert(rows, d.label .. (d.mountPath ~= "" and (" (" .. d.mountPath .. ")") or ""))
end
barWidget.setTooltip(noctalia.tr("tooltip_mounted") .. "\n" .. table.concat(rows, "\n"))
end
noctalia.state.watch("udiskie_devices", function()
render()
end)
function onClick()
noctalia.togglePanel("aristides/udiskie:manager")
end
function onRightClick()
noctalia.runAsync("noctalia msg plugin aristides/udiskie:service all refresh")
end
render()