From aff8c66e7d5a2980826288cc3fccf3939e5c58ba Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 17 Nov 2010 18:06:08 +0100 Subject: [PATCH] Converter: bool settings default to true, nicer quoting of short strings --- convert.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/convert.lua b/convert.lua index b8034a73..5ea0505e 100755 --- a/convert.lua +++ b/convert.lua @@ -1,6 +1,9 @@ #! /usr/bin/lua local function quote(s) + if not s:find("[\n']") then + return "'" .. s .. "'"; + end; local q = ''; while s:find(']' .. q .. ']', 1, true) do q = q .. '='; @@ -64,7 +67,7 @@ local function handle(setting, value) end; if bool_setting[setting] then value = value:lower(); - if value == 'yes' or value == 'true' or value == '1' then + if value == 'yes' or value == 'true' or value == '1' or value == '' then value = 'true'; else value = 'false'; @@ -99,4 +102,4 @@ local config = input:read('*a'); local settings, text = config:match('^(.-)TEXT\n(.*)$'); output:write('conky.config = {\n', settings:gsub('.-\n', convert), '};\n\n'); -output:write('conky.text = ', quote(text), ';\n'); +output:write('conky.text = \n', quote(text), ';\n');