mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-30 02:28:31 +00:00
Converter: bool settings default to true, nicer quoting of short strings
This commit is contained in:
parent
87415d6e36
commit
aff8c66e7d
@ -1,6 +1,9 @@
|
|||||||
#! /usr/bin/lua
|
#! /usr/bin/lua
|
||||||
|
|
||||||
local function quote(s)
|
local function quote(s)
|
||||||
|
if not s:find("[\n']") then
|
||||||
|
return "'" .. s .. "'";
|
||||||
|
end;
|
||||||
local q = '';
|
local q = '';
|
||||||
while s:find(']' .. q .. ']', 1, true) do
|
while s:find(']' .. q .. ']', 1, true) do
|
||||||
q = q .. '=';
|
q = q .. '=';
|
||||||
@ -64,7 +67,7 @@ local function handle(setting, value)
|
|||||||
end;
|
end;
|
||||||
if bool_setting[setting] then
|
if bool_setting[setting] then
|
||||||
value = value:lower();
|
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';
|
value = 'true';
|
||||||
else
|
else
|
||||||
value = 'false';
|
value = 'false';
|
||||||
@ -99,4 +102,4 @@ local config = input:read('*a');
|
|||||||
local settings, text = config:match('^(.-)TEXT\n(.*)$');
|
local settings, text = config:match('^(.-)TEXT\n(.*)$');
|
||||||
|
|
||||||
output:write('conky.config = {\n', settings:gsub('.-\n', convert), '};\n\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');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user