refactor(nextboot-selector): use closure callbacks

This commit is contained in:
Lemmy
2026-07-24 22:38:38 -04:00
parent 51400ced59
commit 9f0dd5f4dc
2 changed files with 10 additions and 11 deletions
+8 -9
View File
@@ -6,7 +6,6 @@ function cfg(key)
return noctalia.getConfig(key) return noctalia.getConfig(key)
end end
local env = getfenv()
local excludedKeywords = cfg("excluded_keywords") local excludedKeywords = cfg("excluded_keywords")
local privilegeCmd = cfg("privilege_command") local privilegeCmd = cfg("privilege_command")
local closeOnSelect = cfg("close_on_select") local closeOnSelect = cfg("close_on_select")
@@ -66,10 +65,10 @@ end
function render(entries) function render(entries)
local entriesButton = {} local entriesButton = {}
for i, entry in ipairs(entries) do for _, entry in ipairs(entries) do
local callBackFn = `setBootNext_{entry.id}` local bootEntry = entry
env[callBackFn] = function() local callBackFn = function()
noctalia.runAsync(`{privilegeCmd} efibootmgr --bootnext {entry.id}`, function(result) noctalia.runAsync(`{privilegeCmd} efibootmgr --bootnext {bootEntry.id}`, function(result)
if not result.timedOut then if not result.timedOut then
if result.exitCode == 0 then if result.exitCode == 0 then
load() load()
@@ -93,12 +92,12 @@ function render(entries)
table.insert( table.insert(
entriesButton, entriesButton,
ui.button({ ui.button({
text = entry.name, text = bootEntry.name,
selected = entry.isSelected, selected = bootEntry.isSelected,
enabled = entry.isActive, enabled = bootEntry.isActive,
onClick = callBackFn, onClick = callBackFn,
contentAlign = "start", contentAlign = "start",
glyph = if entry.isSelected then "circle-check" else "circle", glyph = if bootEntry.isSelected then "circle-check" else "circle",
glyphSize = 18, glyphSize = 18,
}) })
) )
+2 -2
View File
@@ -1,7 +1,7 @@
id = "avivbintangaringga/nextboot-selector" id = "avivbintangaringga/nextboot-selector"
name = "Next Boot Selector" name = "Next Boot Selector"
version = "1.0.0" version = "1.0.1"
plugin_api = 3 plugin_api = 9
icon = "refresh-dot" icon = "refresh-dot"
author = "avivbintangaringga" author = "avivbintangaringga"
description = "Select boot entry for the next reboot" description = "Select boot entry for the next reboot"