summaryrefslogtreecommitdiff
path: root/.i3/scripts
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-09-24 14:03:03 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-09-24 14:03:26 +0200
commitc9e835b33c007604b66b062811178376bae391f2 (patch)
treebba845d44b4623659e2c030ac8838cd1f6c7f1f7 /.i3/scripts
parentadc93aec5dce3929471f6dff61c1a939871fa262 (diff)
downloaddotfiles-c9e835b33c007604b66b062811178376bae391f2.tar.gz
dotfiles-c9e835b33c007604b66b062811178376bae391f2.tar.bz2
dotfiles-c9e835b33c007604b66b062811178376bae391f2.zip
Conky changes
Diffstat (limited to '.i3/scripts')
-rw-r--r--.i3/scripts/conky_helpers.lua (renamed from .i3/scripts/json_escape.lua)10
1 files changed, 9 insertions, 1 deletions
diff --git a/.i3/scripts/json_escape.lua b/.i3/scripts/conky_helpers.lua
index 8723d3e..b796753 100644
--- a/.i3/scripts/json_escape.lua
+++ b/.i3/scripts/conky_helpers.lua
@@ -1,12 +1,20 @@
+-- escape special chars to be usable in JSON
function conky_json(str)
return string.gsub(conky_parse(str), '([\\"])', '\\%1')
end
+-- format strings of 'xxh xxm xxs' as 'hh:mm'
+function conky_utime(str)
+ return string.format("%d:%02d", string.match(conky_parse(str), '(%d+)h (%d+)m (%d+)s'))
+end
+
+-- format all the args as a JSON dictionary
+-- args are as key1, value1, key2, value2, ...
function conky_i3(...)
d = "{"
key = true
for i,v in ipairs(arg) do
- if key then
+ if key then
d = d .. "\"" .. v .. "\":"
key = false
else