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("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), translate("Customizes the behaviour of the device <abbr title=\"Light Emitting Diode\">LED</abbr>s if possible."))
16 local sysfs_path = "/sys/class/leds/"
19 local fs = require "nixio.fs"
20 local util = require "nixio.util"
22 if fs.access(sysfs_path) then
23 leds = util.consume((fs.dir(sysfs_path)))
31 s = m:section(TypedSection, "led", "")
35 function s.parse(self, ...)
36 TypedSection.parse(self, ...)
37 os.execute("/etc/init.d/led enable")
41 s:option(Value, "name", translate("Name"))
44 sysfs = s:option(ListValue, "sysfs", translate("<abbr title=\"Light Emitting Diode\">LED</abbr> Name"))
45 for k, v in ipairs(leds) do
49 s:option(Flag, "default", translate("Default state")).rmempty = false
52 trigger = s:option(ListValue, "trigger", translate("Trigger"))
54 local triggers = fs.readfile(sysfs_path .. leds[1] .. "/trigger")
55 for t in triggers:gmatch("[%w-]+") do
56 trigger:value(t, translate(t:gsub("-", "")))
60 delayon = s:option(Value, "delayon", translate ("On-State Delay"))
61 delayon:depends("trigger", "timer")
63 delayoff = s:option(Value, "delayoff", translate ("Off-State Delay"))
64 delayoff:depends("trigger", "timer")
67 dev = s:option(ListValue, "dev", translate("Device"))
70 dev:depends("trigger", "netdev")
71 for k, v in pairs(luci.sys.net.devices()) do
78 mode = s:option(MultiValue, "mode", translate("Trigger Mode"))
80 mode:depends("trigger", "netdev")
81 mode:value("link", translate("Link On"))
82 mode:value("tx", translate("Transmit"))
83 mode:value("rx", translate("Receive"))