aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO6
-rw-r--r--helpers.lua5
2 files changed, 7 insertions, 4 deletions
diff --git a/TODO b/TODO
index 0f77dfd..5c125f0 100644
--- a/TODO
+++ b/TODO
@@ -5,11 +5,11 @@
* Vicious
+** TODO Consider commiting power drain support to bat.lua
+** TODO Try replacing dio.lua with io.lua
+*** TODO First io.lua should grab data for all devices
** TODO Document contrib widgets in contrib/README
** TODO Consider multigraph, graph stacking, support
-** TODO Consider including this code in format helper
- - return format and format:gsub("${[^}]+}", "")
- - Note: We should then also replace just $1/$2...
** TODO Complete the hddtemp fix
- In certain setups regexp does not match all devices
- The regexp catches the first device name, but last stats
diff --git a/helpers.lua b/helpers.lua
index c61468e..ef92bfa 100644
--- a/helpers.lua
+++ b/helpers.lua
@@ -9,6 +9,7 @@
-- {{{ Grab environment
local pairs = pairs
+local tonumber = tonumber
local io = { open = io.open }
local setmetatable = setmetatable
local getmetatable = getmetatable
@@ -53,7 +54,9 @@ end
-- {{{ Format a string with args
function format(format, args)
for var, val in pairs(args) do
- format = format:gsub("$" .. var, val)
+ format = format:gsub("$" .. (tonumber(var) and var or
+ var:gsub("[-+?*]", function(i) return "%"..i end)),
+ val)
end
return format