diff --git a/vis/.config/vis/visrc.lua b/vis/.config/vis/visrc.lua index bd7755c..1fa3b52 100644 --- a/vis/.config/vis/visrc.lua +++ b/vis/.config/vis/visrc.lua @@ -189,12 +189,27 @@ local function add_global_mark() end end +local lfs = require('lfs') +local theme_modification = 0 +local last_theme = 'default' + function set_current_theme() - local f = io.open(os.getenv('HOME') .. '/.config/xsettingsd/xsettingsd.conf') + local path = os.getenv('HOME') .. '/.config/xsettingsd/xsettingsd.conf' + local m = lfs.attributes(path, 'modification') + if m == theme_modification then + return + end + theme_modification = m + local f = io.open(path) if f then local s = f:read('*all') f:close() - if s:match('light') then + local theme = s:match('light') and 'light' or 'dark' + if theme == last_theme then + return + end + last_theme = theme + if theme == 'light' then vis:command('set theme lupan-light') else vis:command('set theme lupan-dark') @@ -349,7 +364,11 @@ vis.events.subscribe(vis.events.INIT, function() vis:map(vis.modes.NORMAL, ' tl', function() vis:command('set theme lupan-light') end, 'change to light theme') - vis:map(vis.modes.NORMAL, ' tt', set_current_theme) + + vis:map(vis.modes.NORMAL, '', function() + vis:feedkeys('') + set_current_theme() + end, 'Remove all but the count selection column and update theme if needed') set_current_theme() end)