diff --git a/widget/alsa.lua b/widget/alsa.lua index 202dc981..a4ac57ad 100644 --- a/widget/alsa.lua +++ b/widget/alsa.lua @@ -18,7 +18,7 @@ local function factory(args) args = args or {} local alsa = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 5 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end alsa.cmd = args.cmd or "amixer" alsa.channel = args.channel or "Master" @@ -38,10 +38,9 @@ local function factory(args) local l,s = string.match(mixer, "([%d]+)%%.*%[([%l]*)") l = tonumber(l) if alsa.last.level ~= l or alsa.last.status ~= s then - volume_now = { level = l, status = s } - widget = alsa.widget - settings() - alsa.last = volume_now + alsa.now = { level = l, status = s } + settings(alsa.widget, alsa.now) + alsa.last = alsa.now end end) end diff --git a/widget/alsabar.lua b/widget/alsabar.lua index 8e8cd3a8..26a8af17 100644 --- a/widget/alsabar.lua +++ b/widget/alsabar.lua @@ -33,7 +33,7 @@ local function factory(args) args = args or {} local timeout = args.timeout or 5 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end local width = args.width or 63 local height = args.height or 1 local margins = args.margins or 1 @@ -95,12 +95,12 @@ local function factory(args) alsabar.bar.color = alsabar.colors.unmute end - volume_now = { + alsabar.now = { level = alsabar._current_level, status = alsabar._playback } - settings() + settings(alsabar.bar, alsabar.now) if type(callback) == "function" then callback() end end diff --git a/widget/contrib/moc.lua b/widget/contrib/moc.lua index ad6452e2..50975f96 100644 --- a/widget/contrib/moc.lua +++ b/widget/contrib/moc.lua @@ -27,15 +27,15 @@ local function factory(args) local cover_size = args.cover_size or 100 local default_art = args.default_art or "" local followtag = args.followtag or false - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end - moc_notification_preset = { title = "Now playing", timeout = 6 } + local moc_notification_preset = { title = "Now playing", timeout = 6 } helpers.set_map("current moc track", nil) function moc.update() helpers.async("mocp -i", function(f) - moc_now = { + moc.now = { state = "N/A", file = "N/A", artist = "N/A", @@ -47,25 +47,24 @@ local function factory(args) for line in string.gmatch(f, "[^\n]+") do for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do - if k == "State" then moc_now.state = v - elseif k == "File" then moc_now.file = v - elseif k == "Artist" then moc_now.artist = escape_f(v) - elseif k == "SongTitle" then moc_now.title = escape_f(v) - elseif k == "Album" then moc_now.album = escape_f(v) - elseif k == "CurrentTime" then moc_now.elapsed = escape_f(v) - elseif k == "TotalTime" then moc_now.total = escape_f(v) + if k == "State" then moc.now.state = v + elseif k == "File" then moc.now.file = v + elseif k == "Artist" then moc.now.artist = escape_f(v) + elseif k == "SongTitle" then moc.now.title = escape_f(v) + elseif k == "Album" then moc.now.album = escape_f(v) + elseif k == "CurrentTime" then moc.now.elapsed = escape_f(v) + elseif k == "TotalTime" then moc.now.total = escape_f(v) end end end - moc_notification_preset.text = string.format("%s (%s) - %s\n%s", moc_now.artist, - moc_now.album, moc_now.total, moc_now.title) - widget = moc.widget - settings() + moc_notification_preset.text = string.format("%s (%s) - %s\n%s", moc.now.artist, + moc.now.album, moc.now.total, moc.now.title) + settings(moc.widget, moc.now) - if moc_now.state == "PLAY" then - if moc_now.title ~= helpers.get_map("current moc track") then - helpers.set_map("current moc track", moc_now.title) + if moc.now.state == "PLAY" then + if moc.now.title ~= helpers.get_map("current moc track") then + helpers.set_map("current moc track", moc.now.title) if followtag then moc_notification_preset.screen = focused() end @@ -76,14 +75,14 @@ local function factory(args) replaces_id = moc.id, } - local path = string.format("%s/%s", music_dir, string.match(moc_now.file, ".*/")) + local path = string.format("%s/%s", music_dir, string.match(moc.now.file, ".*/")) local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path, cover_pattern) helpers.async({ shell, "-c", cover }, function(current_icon) common.icon = current_icon:gsub("\n", "") moc.id = naughty.notify(common).id end) end - elseif moc_now.state ~= "PAUSE" then + elseif moc.now.state ~= "PAUSE" then helpers.set_map("current moc track", nil) end end) diff --git a/widget/cpu.lua b/widget/cpu.lua index 6c511158..4a2b854a 100644 --- a/widget/cpu.lua +++ b/widget/cpu.lua @@ -19,7 +19,7 @@ local function factory(args) local cpu = { core = {}, widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end function cpu.update() -- Read the amount of time the CPUs have spent performing @@ -60,11 +60,9 @@ local function factory(args) end end - cpu_now = cpu.core - cpu_now.usage = cpu_now[0].usage - widget = cpu.widget - - settings() + cpu.now = cpu.core + cpu.now.usage = cpu.now[0].usage + settings(cpu.widget, cpu.now) end helpers.newtimer("cpu", timeout, cpu.update) diff --git a/widget/fs.lua b/widget/fs.lua index b3a2dada..ae316e02 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -58,7 +58,7 @@ local function factory(args) local partition = args.partition local threshold = args.threshold or 99 local showpopup = args.showpopup or "on" - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end fs.followtag = args.followtag or false fs.notification_preset = args.notification_preset @@ -73,7 +73,7 @@ local function factory(args) local function update_synced() local pathlen = 10 - fs_now = {} + fs.now = {} local notifypaths = {} for _, mount in ipairs(Gio.unix_mounts_get()) do @@ -89,7 +89,7 @@ local function factory(args) if size > 0 then local units = math.floor(math.log(size)/math.log(1024)) - fs_now[path] = { + fs.now[path] = { units = fs.units[units], percentage = math.floor(100 * used / size), -- used percentage size = size / math.pow(1024, units), @@ -97,7 +97,7 @@ local function factory(args) free = free / math.pow(1024, units) } - if fs_now[path].percentage > 0 then -- don't notify unused file systems + if fs.now[path].percentage > 0 then -- don't notify unused file systems notifypaths[#notifypaths+1] = path if #path > pathlen then @@ -108,15 +108,14 @@ local function factory(args) end end - widget = fs.widget - settings() + settings(fs.widget, fs.now) - if partition and fs_now[partition] and fs_now[partition].percentage >= threshold then + if partition and fs.now[partition] and fs.now[partition].percentage >= threshold then if not helpers.get_map(partition) then naughty.notify { preset = naughty.config.presets.critical, title = "Warning", - text = string.format("%s is above %d%% (%d%%)", partition, threshold, fs_now[partition].percentage) + text = string.format("%s is above %d%% (%d%%)", partition, threshold, fs.now[partition].percentage) } helpers.set_map(partition, true) else @@ -128,7 +127,7 @@ local function factory(args) local notifytable = { [1] = string.format(fmt, "path", "used", "free", "size") } fmt = "\n%-" .. tostring(pathlen) .. "s %3s%%\t%6.2f\t%6.2f %s" for _, path in ipairs(notifypaths) do - notifytable[#notifytable+1] = string.format(fmt, path, fs_now[path].percentage, fs_now[path].free, fs_now[path].size, fs_now[path].units) + notifytable[#notifytable+1] = string.format(fmt, path, fs.now[path].percentage, fs.now[path].free, fs.now[path].size, fs.now[path].units) end fs.notification_preset.text = tconcat(notifytable) diff --git a/widget/imap.lua b/widget/imap.lua index e3f7baaa..98b8f13b 100644 --- a/widget/imap.lua +++ b/widget/imap.lua @@ -29,14 +29,14 @@ local function factory(args) local is_plain = args.is_plain or false local followtag = args.followtag or false local notify = args.notify or "on" - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end local head_command = "curl --connect-timeout 3 -fsm 3" local request = "-X 'STATUS INBOX (MESSAGES RECENT UNSEEN)'" if not server or not mail or not password then return end - mail_notification_preset = { + local mail_notification_preset = { icon = helpers.icons_dir .. "mail.png", position = "top_left" } @@ -65,14 +65,13 @@ local function factory(args) head_command, server, port, mail, password, request) helpers.async(curl, function(f) - imap_now = { ["MESSAGES"] = 0, ["RECENT"] = 0, ["UNSEEN"] = 0 } + imap.now = { ["MESSAGES"] = 0, ["RECENT"] = 0, ["UNSEEN"] = 0 } - for s,d in f:gmatch("(%w+)%s+(%d+)") do imap_now[s] = tonumber(d) end - mailcount = imap_now["UNSEEN"] -- backwards compatibility - widget = imap.widget + for s,d in f:gmatch("(%w+)%s+(%d+)") do imap.now[s] = tonumber(d) end - settings() + settings(imap.widget, imap.now) + local mailcount = imap.now["UNSEEN"] if notify == "on" and mailcount and mailcount >= 1 and mailcount > helpers.get_map(mail) then if followtag then mail_notification_preset.screen = awful.screen.focused() end naughty.notify { @@ -81,7 +80,7 @@ local function factory(args) } end - helpers.set_map(mail, imap_now["UNSEEN"]) + helpers.set_map(mail, imap.now["UNSEEN"]) end) end diff --git a/widget/mem.lua b/widget/mem.lua index 03184941..d7cce8dd 100644 --- a/widget/mem.lua +++ b/widget/mem.lua @@ -18,29 +18,28 @@ local function factory(args) local mem = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end function mem.update() - mem_now = {} + mem.now = {} for line in lines("/proc/meminfo") do for k, v in gmatch(line, "([%a]+):[%s]+([%d]+).+") do - if k == "MemTotal" then mem_now.total = floor(v / 1024 + 0.5) - elseif k == "MemFree" then mem_now.free = floor(v / 1024 + 0.5) - elseif k == "Buffers" then mem_now.buf = floor(v / 1024 + 0.5) - elseif k == "Cached" then mem_now.cache = floor(v / 1024 + 0.5) - elseif k == "SwapTotal" then mem_now.swap = floor(v / 1024 + 0.5) - elseif k == "SwapFree" then mem_now.swapf = floor(v / 1024 + 0.5) - elseif k == "SReclaimable" then mem_now.srec = floor(v / 1024 + 0.5) + if k == "MemTotal" then mem.now.total = floor(v / 1024 + 0.5) + elseif k == "MemFree" then mem.now.free = floor(v / 1024 + 0.5) + elseif k == "Buffers" then mem.now.buf = floor(v / 1024 + 0.5) + elseif k == "Cached" then mem.now.cache = floor(v / 1024 + 0.5) + elseif k == "SwapTotal" then mem.now.swap = floor(v / 1024 + 0.5) + elseif k == "SwapFree" then mem.now.swapf = floor(v / 1024 + 0.5) + elseif k == "SReclaimable" then mem.now.srec = floor(v / 1024 + 0.5) end end end - mem_now.used = mem_now.total - mem_now.free - mem_now.buf - mem_now.cache - mem_now.srec - mem_now.swapused = mem_now.swap - mem_now.swapf - mem_now.perc = math.floor(mem_now.used / mem_now.total * 100) + mem.now.used = mem.now.total - mem.now.free - mem.now.buf - mem.now.cache - mem.now.srec + mem.now.swapused = mem.now.swap - mem.now.swapf + mem.now.perc = math.floor(mem.now.used / mem.now.total * 100) - widget = mem.widget - settings() + settings(mem.widget, mem.now) end helpers.newtimer("mem", timeout, mem.update) diff --git a/widget/mpd.lua b/widget/mpd.lua index 55d3649b..c5fb7d41 100644 --- a/widget/mpd.lua +++ b/widget/mpd.lua @@ -32,19 +32,19 @@ local function factory(args) local default_art = args.default_art local notify = args.notify or "on" local followtag = args.followtag or false - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end local mpdh = string.format("telnet://%s:%s", host, port) local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password) local cmd = string.format("%s | curl --connect-timeout 1 -fsm 3 %s", echo, mpdh) - mpd_notification_preset = { title = "Now playing", timeout = 6 } + local mpd_notification_preset = { title = "Now playing", timeout = 6 } helpers.set_map("current mpd track", nil) function mpd.update() helpers.async({ shell, "-c", cmd }, function(f) - mpd_now = { + mpd.now = { random_mode = false, single_mode = false, repeat_mode = false, @@ -67,36 +67,35 @@ local function factory(args) for line in string.gmatch(f, "[^\n]+") do for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do - if k == "state" then mpd_now.state = v - elseif k == "file" then mpd_now.file = v - elseif k == "Name" then mpd_now.name = escape_f(v) - elseif k == "Artist" then mpd_now.artist = escape_f(v) - elseif k == "Title" then mpd_now.title = escape_f(v) - elseif k == "Album" then mpd_now.album = escape_f(v) - elseif k == "Genre" then mpd_now.genre = escape_f(v) - elseif k == "Track" then mpd_now.track = escape_f(v) - elseif k == "Date" then mpd_now.date = escape_f(v) - elseif k == "Time" then mpd_now.time = v - elseif k == "elapsed" then mpd_now.elapsed = string.match(v, "%d+") - elseif k == "song" then mpd_now.pls_pos = v - elseif k == "playlistlength" then mpd_now.pls_len = v - elseif k == "repeat" then mpd_now.repeat_mode = v ~= "0" - elseif k == "single" then mpd_now.single_mode = v ~= "0" - elseif k == "random" then mpd_now.random_mode = v ~= "0" - elseif k == "consume" then mpd_now.consume_mode = v ~= "0" - elseif k == "volume" then mpd_now.volume = v + if k == "state" then mpd.now.state = v + elseif k == "file" then mpd.now.file = v + elseif k == "Name" then mpd.now.name = escape_f(v) + elseif k == "Artist" then mpd.now.artist = escape_f(v) + elseif k == "Title" then mpd.now.title = escape_f(v) + elseif k == "Album" then mpd.now.album = escape_f(v) + elseif k == "Genre" then mpd.now.genre = escape_f(v) + elseif k == "Track" then mpd.now.track = escape_f(v) + elseif k == "Date" then mpd.now.date = escape_f(v) + elseif k == "Time" then mpd.now.time = v + elseif k == "elapsed" then mpd.now.elapsed = string.match(v, "%d+") + elseif k == "song" then mpd.now.pls_pos = v + elseif k == "playlistlength" then mpd.now.pls_len = v + elseif k == "repeat" then mpd.now.repeat_mode = v ~= "0" + elseif k == "single" then mpd.now.single_mode = v ~= "0" + elseif k == "random" then mpd.now.random_mode = v ~= "0" + elseif k == "consume" then mpd.now.consume_mode = v ~= "0" + elseif k == "volume" then mpd.now.volume = v end end end - mpd_notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist, - mpd_now.album, mpd_now.date, mpd_now.title) - widget = mpd.widget - settings() + mpd_notification_preset.text = string.format("%s (%s) - %s\n%s", mpd.now.artist, + mpd.now.album, mpd.now.date, mpd.now.title) + settings(mpd.widget, mpd.now) - if mpd_now.state == "play" then - if notify == "on" and mpd_now.title ~= helpers.get_map("current mpd track") then - helpers.set_map("current mpd track", mpd_now.title) + if mpd.now.state == "play" then + if notify == "on" and mpd.now.title ~= helpers.get_map("current mpd track") then + helpers.set_map("current mpd track", mpd.now.title) if followtag then mpd_notification_preset.screen = focused() end @@ -107,8 +106,8 @@ local function factory(args) replaces_id = mpd.id } - if not string.match(mpd_now.file, "http.*://") then -- local file instead of http stream - local path = string.format("%s/%s", music_dir, string.match(mpd_now.file, ".*/")) + if not string.match(mpd.now.file, "http.*://") then -- local file instead of http stream + local path = string.format("%s/%s", music_dir, string.match(mpd.now.file, ".*/")) local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path:gsub("'", "'\\''"), cover_pattern) helpers.async({ shell, "-c", cover }, function(current_icon) @@ -121,7 +120,7 @@ local function factory(args) end end - elseif mpd_now.state ~= "pause" then + elseif mpd.now.state ~= "pause" then helpers.set_map("current mpd track", nil) end end) diff --git a/widget/net.lua b/widget/net.lua index 9b7b165f..cea7af23 100644 --- a/widget/net.lua +++ b/widget/net.lua @@ -25,7 +25,7 @@ local function factory(args) local eth_state = args.eth_state or "off" local screen = args.screen or 1 local format = args.format or "%.1f" - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end -- Compatibility with old API where iface was a string corresponding to 1 interface net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or @@ -42,7 +42,7 @@ local function factory(args) function net.update() -- These are the totals over all specified interfaces - net_now = { + net.now = { devices = {}, -- Bytes since last iteration sent = 0, @@ -61,8 +61,8 @@ local function factory(args) dev_now.sent = (now_t - dev_before.last_t) / timeout / units dev_now.received = (now_r - dev_before.last_r) / timeout / units - net_now.sent = net_now.sent + dev_now.sent - net_now.received = net_now.received + dev_now.received + net.now.sent = net.now.sent + dev_now.sent + net.now.received = net.now.received + dev_now.received dev_now.sent = string.format(format, dev_now.sent) dev_now.received = string.format(format, dev_now.received) @@ -100,18 +100,17 @@ local function factory(args) helpers.set_map(dev, true) end - net_now.carrier = dev_now.carrier - net_now.state = dev_now.state - net_now.devices[dev] = dev_now - -- net_now.sent and net_now.received will be + net.now.carrier = dev_now.carrier + net.now.state = dev_now.state + net.now.devices[dev] = dev_now + -- net.now.sent and net.now.received will be -- the totals across all specified devices end - net_now.sent = string.format(format, net_now.sent) - net_now.received = string.format(format, net_now.received) + net.now.sent_string = string.format(format, net.now.sent) + net.now.received_string = string.format(format, net.now.received) - widget = net.widget - settings() + settings(net.widget, net.now) end helpers.newtimer("network", timeout, net.update) diff --git a/widget/pulse.lua b/widget/pulse.lua index 69f4d706..59e87de2 100644 --- a/widget/pulse.lua +++ b/widget/pulse.lua @@ -19,34 +19,33 @@ local function factory(args) local pulse = { widget = args.widget or wibox.widget.textbox(), device = "N/A" } local timeout = args.timeout or 5 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end pulse.devicetype = args.devicetype or "sink" - pulse.cmd = args.cmd or "pacmd list-" .. pulse.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" + pulse.cmd = args.cmd or string.format("pacmd list-%ss | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'", pulse.devicetype) function pulse.update() helpers.async({ shell, "-c", type(pulse.cmd) == "string" and pulse.cmd or pulse.cmd() }, function(s) - volume_now = { + pulse.now = { index = string.match(s, "index: (%S+)") or "N/A", device = string.match(s, "device.string = \"(%S+)\"") or "N/A", muted = string.match(s, "muted: (%S+)") or "N/A" } - pulse.device = volume_now.index + pulse.device = pulse.now.index local ch = 1 - volume_now.channel = {} + pulse.now.channel = {} for v in string.gmatch(s, ":.-(%d+)%%") do - volume_now.channel[ch] = v + pulse.now.channel[ch] = v ch = ch + 1 end - volume_now.left = volume_now.channel[1] or "N/A" - volume_now.right = volume_now.channel[2] or "N/A" + pulse.now.left = pulse.now.channel[1] or "N/A" + pulse.now.right = pulse.now.channel[2] or "N/A" - widget = pulse.widget - settings() + settings(pulse.widget, pulse.now) end) end diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 19e73b96..58d01154 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -35,7 +35,7 @@ local function factory(args) args = args or {} local timeout = args.timeout or 5 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end local width = args.width or 63 local height = args.height or 1 local margins = args.margins or 1 @@ -51,7 +51,7 @@ local function factory(args) pulsebar.followtag = args.followtag or false pulsebar.notification_preset = args.notification_preset pulsebar.devicetype = args.devicetype or "sink" - pulsebar.cmd = args.cmd or "pacmd list-" .. pulsebar.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" + pulsebar.cmd = args.cmd or string.format("pacmd list-%ss | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'", pulsebar.devicetype) if not pulsebar.notification_preset then pulsebar.notification_preset = { @@ -76,26 +76,26 @@ local function factory(args) function pulsebar.update(callback) helpers.async({ awful.util.shell, "-c", type(pulsebar.cmd) == "string" and pulsebar.cmd or pulsebar.cmd() }, function(s) - volume_now = { + pulsebar.now = { index = string.match(s, "index: (%S+)") or "N/A", device = string.match(s, "device.string = \"(%S+)\"") or "N/A", muted = string.match(s, "muted: (%S+)") or "N/A" } - pulsebar.device = volume_now.index + pulsebar.device = pulsebar.now.index local ch = 1 - volume_now.channel = {} + pulsebar.now.channel = {} for v in string.gmatch(s, ":.-(%d+)%%") do - volume_now.channel[ch] = v + pulsebar.now.channel[ch] = v ch = ch + 1 end - volume_now.left = volume_now.channel[1] or "N/A" - volume_now.right = volume_now.channel[2] or "N/A" + pulsebar.now.left = pulsebar.now.channel[1] or "N/A" + pulsebar.now.right = pulsebar.now.channel[2] or "N/A" - local volu = volume_now.left - local mute = volume_now.muted + local volu = pulsebar.now.left + local mute = pulsebar.now.muted if volu:match("N/A") or mute:match("N/A") then return end @@ -114,7 +114,7 @@ local function factory(args) pulsebar.bar.background_color = pulsebar.colors.background end - settings() + settings(pulsebar.bar, pulsebar.now) if type(callback) == "function" then callback() end end diff --git a/widget/sysload.lua b/widget/sysload.lua index 72605249..f36b8614 100644 --- a/widget/sysload.lua +++ b/widget/sysload.lua @@ -16,19 +16,18 @@ local open, match = io.open, string.match local function factory(args) args = args or {} - local sysload = { widget = args.widget or wibox.widget.textbox() } + local sysload = { widget = args.widget or wibox.widget.textbox(), now = {} } local timeout = args.timeout or 2 - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end function sysload.update() local f = open("/proc/loadavg") local ret = f:read("*all") f:close() - load_1, load_5, load_15 = match(ret, "([^%s]+) ([^%s]+) ([^%s]+)") + sysload.now[1], sysload.now[5], sysload.now[15] = match(ret, "([^%s]+) ([^%s]+) ([^%s]+)") - widget = sysload.widget - settings() + settings(sysload.widget, sysload.now) end helpers.newtimer("sysload", timeout, sysload.update) diff --git a/widget/temp.lua b/widget/temp.lua index 99f87007..fb5ef56e 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -19,26 +19,25 @@ local function factory(args) local timeout = args.timeout or 30 local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp" local format = args.format or "%.1f" - local settings = args.settings or function() end + local settings = args.settings or function(_, _) end function temp.update() helpers.async({"find", "/sys/devices", "-type", "f", "-name", "*temp*"}, function(f) - temp_now = {} + temp.now = {} local temp_fl, temp_value for t in f:gmatch("[^\n]+") do temp_fl = helpers.first_line(t) if temp_fl then temp_value = tonumber(temp_fl) - temp_now[t] = temp_value and temp_value/1e3 or temp_fl + temp.now[t] = temp_value and temp_value/1e3 or temp_fl end end - if temp_now[tempfile] then - coretemp_now = string.format(format, temp_now[tempfile]) + if temp.now[tempfile] then + temp.now.coretemp = string.format(format, temp.now[tempfile]) else - coretemp_now = "N/A" + temp.now.coretemp = "N/A" end - widget = temp.widget - settings() + settings(temp.widget, temp.now) end) end