From c9e835b33c007604b66b062811178376bae391f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Tue, 24 Sep 2013 14:03:03 +0200 Subject: Conky changes --- .i3/conkyrc | 8 ++++---- .i3/scripts/conky_helpers.lua | 31 +++++++++++++++++++++++++++++++ .i3/scripts/json_escape.lua | 23 ----------------------- 3 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 .i3/scripts/conky_helpers.lua delete mode 100644 .i3/scripts/json_escape.lua (limited to '.i3') diff --git a/.i3/conkyrc b/.i3/conkyrc index ca8be29..f7e4a3c 100644 --- a/.i3/conkyrc +++ b/.i3/conkyrc @@ -32,7 +32,7 @@ override_utf8_locale yes # set to 1 to disable averaging cpu_avg_samples 2 -lua_load $HOME/.i3/scripts/json_escape.lua +lua_load $HOME/.i3/scripts/conky_helpers.lua template0 "$HOME/.i3/icons/\1.xbm" @@ -52,9 +52,9 @@ TEXT "align" : "right"\ },\ {\ - "full_text" : "${mem}",\ + "full_text" : " ${mem}",\ "icon" : ${template0 load},\ - "min_width" : "1000M",\ + "min_width" : " 1000M",\ "color" : "\#${if_match ${memperc}<90}ffffff${else}ff0000${endif}"\ },\ {\ @@ -62,7 +62,7 @@ TEXT "icon" : ${template0 temp}\ },\ {\ - "full_text" : "${if_up eth0}${addr}${else}(down)${endif}",\ + "full_text" : " ${if_up eth0}${addr}${else}(down)${endif}",\ "icon" : ${template0 net-wired},\ "color" : "\#${if_up eth0}ffffff${else}ff0000${endif}"\ },\ diff --git a/.i3/scripts/conky_helpers.lua b/.i3/scripts/conky_helpers.lua new file mode 100644 index 0000000..b796753 --- /dev/null +++ b/.i3/scripts/conky_helpers.lua @@ -0,0 +1,31 @@ +-- 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 + 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 diff --git a/.i3/scripts/json_escape.lua b/.i3/scripts/json_escape.lua deleted file mode 100644 index 8723d3e..0000000 --- a/.i3/scripts/json_escape.lua +++ /dev/null @@ -1,23 +0,0 @@ -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 -- cgit v1.2.3