handle booleans better in main.lua

This commit is contained in:
petrucci4prez 2017-07-17 23:30:34 -04:00
parent fb5680b871
commit 2d1e4b3d9c
3 changed files with 10 additions and 16 deletions

View File

@ -137,7 +137,7 @@ local __collectgarbage = collectgarbage
local __os_execute = os.execute local __os_execute = os.execute
local using_ac = function() local using_ac = function()
if util.conky('${acpiacadapter AC}') == 'on-line' then return 0 end return util.conky('${acpiacadapter AC}') == 'on-line'
end end
local current_last_log_entry = util.execute_cmd('tail -1 /var/log/pacman.log') local current_last_log_entry = util.execute_cmd('tail -1 /var/log/pacman.log')
@ -184,7 +184,7 @@ function conky_main()
t2 = updates % (UPDATE_FREQUENCY * 300) t2 = updates % (UPDATE_FREQUENCY * 300)
end end
local log_is_changed = 1 local log_is_changed = false
if t2 == 0 then log_is_changed = check_if_log_changed() end if t2 == 0 then log_is_changed = check_if_log_changed() end
local interface_changed = check_interface() local interface_changed = check_interface()

View File

@ -13,11 +13,6 @@ local PACMAN_TABLE = {
'pacman -Qmq' 'pacman -Qmq'
} }
local _INITIAL_PGK_CNT_ = {}
for i, cmd in pairs(PACMAN_TABLE) do
_INITIAL_PGK_CNT_[i] = util.line_count(util.execute_cmd(cmd))
end
local _TEXT_SPACING_ = 20 local _TEXT_SPACING_ = 20
local header = Widget.Header{ local header = Widget.Header{
@ -43,13 +38,12 @@ local info = Widget.TextColumn{
spacing = _TEXT_SPACING_, spacing = _TEXT_SPACING_,
x_align = 'right', x_align = 'right',
text_color = schema.blue, text_color = schema.blue,
unpack(_INITIAL_PGK_CNT_) num_rows = 5
} }
Widget = nil Widget = nil
schema = nil schema = nil
_TEXT_SPACING_ = nil _TEXT_SPACING_ = nil
_INITIAL_PGK_CNT_ = nil
local update = function(cr) local update = function(cr)
for i, cmd in pairs(PACMAN_TABLE) do for i, cmd in pairs(PACMAN_TABLE) do
@ -57,8 +51,8 @@ local update = function(cr)
end end
end end
local draw = function(cr, current_interface, trigger) local draw = function(cr, current_interface, log_is_changed)
if trigger == 0 then update(cr) end if log_is_changed then update(cr) end
if current_interface == 0 then if current_interface == 0 then
Text.draw(header.text, cr) Text.draw(header.text, cr)

View File

@ -40,19 +40,19 @@ local info = Widget.TextColumn{
x_align = 'right', x_align = 'right',
text_color = schema.blue, text_color = schema.blue,
util.conky('$kernel'), util.conky('$kernel'),
util.conky('$uptime'), '<row2>',
extract_date(UPGRADE_CMD), '<row3>',
extract_date(SYNC_CMD) '<row4>'
} }
Widget = nil Widget = nil
schema = nil schema = nil
_TEXT_SPACING_ = nil _TEXT_SPACING_ = nil
local draw = function(cr, current_interface, trigger) local draw = function(cr, current_interface, log_is_changed)
TextColumn.set(info, cr, 2, util.conky('$uptime')) TextColumn.set(info, cr, 2, util.conky('$uptime'))
if trigger == 0 then if log_is_changed then
TextColumn.set(info, cr, 3, extract_date(UPGRADE_CMD)) TextColumn.set(info, cr, 3, extract_date(UPGRADE_CMD))
TextColumn.set(info, cr, 4, extract_date(SYNC_CMD)) TextColumn.set(info, cr, 4, extract_date(SYNC_CMD))
end end