diff --git a/audio-switcher/panel.luau b/audio-switcher/panel.luau index 0cfdb53..5187be8 100644 --- a/audio-switcher/panel.luau +++ b/audio-switcher/panel.luau @@ -37,7 +37,6 @@ local requestCounter = 0 local outputVolumeCommitValue = nil local inputVolumeCommitValue = nil local volumeControlRevision = 0 -local env = getfenv() local render local ICON_STYLE_VALUES = { "automatic", "speaker", "over_ear", "tws", "wired" } @@ -64,12 +63,6 @@ local function sendCommand(action, values) return command.requestId end -local function rowCallback(prefix, index, callback) - local name = prefix .. "_" .. tostring(index) - env[name] = callback - return name -end - local function activeDevice(kind) local devices = kind == "output" and asArray(snapshot.outputs) or asArray(snapshot.inputs) for _, device in ipairs(devices) do @@ -203,21 +196,21 @@ local function editor(device) return ui.column({ gap = 7, padding = 10, radius = 9, fill = "surface_variant/0.45", border = "primary/0.35", borderWidth = 1 }, children) end -local function deviceRow(device, index, kind) - local useAction = rowCallback("onUse", index, function() +local function deviceRow(device, kind) + local useAction = function() sendCommand(kind == "output" and "set_output" or "set_input", { id = device.id }) - end) - local editAction = rowCallback("onEdit", index, function() + end + local editAction = function() editingId = device.id editAlias = tostring(device.name or "") editIconStyle = tostring(device.iconStyle or "automatic") editSlot = device.slot and tostring(device.slot) or "" feedback = "" render() - end) - local hideAction = rowCallback("onHide", index, function() + end + local hideAction = function() sendCommand("set_hidden", { id = device.id, kind = kind, hidden = not device.hidden }) - end) + end local actionText = device.active and tr("device.current") or (device.bluetooth and not device.available and tr("actions.connect_and_use") or tr("actions.use")) local actionVariant = device.active and "ghost" or "primary" @@ -266,11 +259,9 @@ end local function deviceList(kind) local source = kind == "output" and asArray(snapshot.outputs) or asArray(snapshot.inputs) local rows = {} - local callbackIndex = kind == "output" and 0 or 1000 for _, device in ipairs(source) do if showHidden or not device.hidden then - table.insert(rows, deviceRow(device, callbackIndex, kind)) - callbackIndex += 1 + table.insert(rows, deviceRow(device, kind)) end end if #rows == 0 then diff --git a/audio-switcher/plugin.toml b/audio-switcher/plugin.toml index 901233b..432cf3d 100644 --- a/audio-switcher/plugin.toml +++ b/audio-switcher/plugin.toml @@ -1,7 +1,7 @@ id = "blackbartblues/audio-switcher" name = "Audio Switcher" -version = "0.1.0" -plugin_api = 5 +version = "0.1.1" +plugin_api = 9 author = "blackbartblues" license = "MIT" icon = "switch-horizontal"