summaryrefslogtreecommitdiff
path: root/.i3/scripts
diff options
context:
space:
mode:
Diffstat (limited to '.i3/scripts')
-rw-r--r--.i3/scripts/json_escape.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/.i3/scripts/json_escape.lua b/.i3/scripts/json_escape.lua
index 03860b7..1715738 100644
--- a/.i3/scripts/json_escape.lua
+++ b/.i3/scripts/json_escape.lua
@@ -1,3 +1,23 @@
function conky_json(str)
return string.gsub(conky_parse(str), '[\\"]', '\\%1')
end
+
+function conky_i3(...)
+ d = "{"
+ key = true
+ for i,v in ipairs(arg) do
+ if key then
+ d = d .. "\"" .. v .. "\":"
+ key = false
+ else
+ d = d .. conky_parse(v)
+ if string.sub(v, -1) == '"' then
+ if i < table.getn(arg) then d = d .. "," end
+ key = true
+ else
+ d = d .. " "
+ end
+ end
+ end
+ return d .. "}"
+end