2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 m = Map("system", translate("leds"), translate("leds_desc"))
16 local sysfs_path = "/sys/class/leds/"
19 if luci.fs.access(sysfs_path) then
20 for k, v in pairs(luci.fs.dir(sysfs_path)) do
21 if v ~= "." and v ~= ".." then
32 s = m:section(TypedSection, "led", "")
36 function s.parse(self, ...)
37 TypedSection.parse(self, ...)
38 os.execute("/etc/init.d/led enable")
42 s:option(Value, "name")
45 sysfs = s:option(ListValue, "sysfs")
46 for k, v in ipairs(leds) do
50 s:option(Flag, "default").rmempty = true
53 trigger = s:option(ListValue, "trigger")
55 local triggers = luci.fs.readfile(sysfs_path .. leds[1] .. "/trigger")
56 for t in triggers:gmatch("[%w-]+") do
57 trigger:value(t, translate("system_led_trigger_" .. t:gsub("-", "")))
61 delayon = s:option(Value, "delayon")
62 delayon:depends("trigger", "timer")
64 delayoff = s:option(Value, "delayoff")
65 delayoff:depends("trigger", "timer")
68 dev = s:option(ListValue, "dev")
71 dev:depends("trigger", "netdev")
72 for k, v in pairs(luci.sys.net.devices()) do
79 mode = s:option(MultiValue, "mode")
81 mode:depends("trigger", "netdev")
82 mode:value("link", translate("system_led_mode_link"))
83 mode:value("tx", translate("system_led_mode_tx"))
84 mode:value("rx", translate("system_led_mode_rx"))