mirror of https://github.com/lcpz/lain.git
Add format option for net and temp widget (#523)
This commit is contained in:
parent
4933d6cb27
commit
6a06d3cb79
|
@ -24,6 +24,7 @@ local function factory(args)
|
|||
local wifi_state = args.wifi_state or "off"
|
||||
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
|
||||
|
||||
-- Compatibility with old API where iface was a string corresponding to 1 interface
|
||||
|
@ -63,8 +64,8 @@ local function factory(args)
|
|||
net_now.sent = net_now.sent + dev_now.sent
|
||||
net_now.received = net_now.received + dev_now.received
|
||||
|
||||
dev_now.sent = string.format("%.1f", dev_now.sent)
|
||||
dev_now.received = string.format("%.1f", dev_now.received)
|
||||
dev_now.sent = string.format(format, dev_now.sent)
|
||||
dev_now.received = string.format(format, dev_now.received)
|
||||
|
||||
dev_now.last_t = now_t
|
||||
dev_now.last_r = now_r
|
||||
|
@ -106,8 +107,8 @@ local function factory(args)
|
|||
-- the totals across all specified devices
|
||||
end
|
||||
|
||||
net_now.sent = string.format("%.1f", net_now.sent)
|
||||
net_now.received = string.format("%.1f", net_now.received)
|
||||
net_now.sent = string.format(format, net_now.sent)
|
||||
net_now.received = string.format(format, net_now.received)
|
||||
|
||||
widget = net.widget
|
||||
settings()
|
||||
|
|
|
@ -18,6 +18,7 @@ local function factory(args)
|
|||
local temp = { widget = args.widget or wibox.widget.textbox() }
|
||||
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
|
||||
|
||||
function temp.update()
|
||||
|
@ -31,7 +32,7 @@ local function factory(args)
|
|||
temp_now[t] = temp_value and temp_value/1e3 or temp_fl
|
||||
end
|
||||
end
|
||||
coretemp_now = temp_now[tempfile] or "N/A"
|
||||
coretemp_now = string.format(format, temp_now[tempfile]) or "N/A"
|
||||
widget = temp.widget
|
||||
settings()
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue