From 83e727a4b34eeb7bc16134c43de24f07570145d3 Mon Sep 17 00:00:00 2001 From: Andrey Burov Date: Thu, 1 Feb 2018 13:15:56 +0300 Subject: [PATCH] JSON formating --- docs/user-contributed/conky-i3bar.html | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/user-contributed/conky-i3bar.html b/docs/user-contributed/conky-i3bar.html index 538f123..a9d94b3 100644 --- a/docs/user-contributed/conky-i3bar.html +++ b/docs/user-contributed/conky-i3bar.html @@ -47,11 +47,11 @@ Here's a sample JSON text for achieving our goal: [ []. - [ { "full_text":"Home 84.0G Free", "color":"#ffffff" }, - { "full_text":"RAM 32%" , "color":"#ffffff" } ], + [ { "full_text": "Home 84.0G Free", "color": "#ffffff" }, + { "full_text": "RAM 32%" , "color": "#ffffff" } ], - [ { "full_text":"Home 84.0G Free", "color":"#ffffff" }, - { "full_text":"RAM 34%" , "color":"#ffffff" } ], + [ { "full_text": "Home 84.0G Free", "color": "#ffffff" }, + { "full_text": "RAM 34%" , "color": "#ffffff" } ], [....], [....], @@ -104,8 +104,10 @@ In the i3 config file the bar config will be something like that Now we have to write a ~/.conkyrc file in order to obtain the desired status:

-
[{ "full_text":"Home 84.0G Free" , "color":"#ffffff" },
- { "full_text":"RAM 32%" , "color":"#ffffff" }],
+
[
+    { "full_text": "Home 84.0G Free" , "color": "#ffffff" },
+    { "full_text": "RAM 32%" , "color": "#ffffff" }
+],

Here's a sample conkyrc that updates every 2 seconds. Just to make things a litte bit more exciting @@ -145,15 +147,12 @@ we put a condition in the script in order to write the occupied RAM in red if th -- number of cpu samples to average -- set to 1 to disable averaging cpu_avg_samples = 2, - - -- Stuff after 'TEXT' will be formatted on screen }; conky.text = [[ -{% raw %} -[{ "full_text" : "Home ${fs_free /home} Free" , "color" : "\#ffffff" }, -{ "full_text" : "RAM ${memperc}%" , "color" : -${if_match ${memperc}<90}"\#ffffff"${else}"\#ff0000"${endif} }], -{% endraw %} +{% raw %}[ + { "full_text": "Home ${fs_free /home} Free" , "color": "\#ffffff" }, + { "full_text": "RAM ${memperc}%" , "color": ${if_match ${memperc}<90}"\#ffffff"${else}"\#ff0000"${endif} } +],{% endraw %} ]]; /tt> -- 2.39.5