From e6cb4df579a9fb0e618eee5c37fac73230742241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Fri, 26 Sep 2025 23:11:21 +0200 Subject: [PATCH] vis: update theme on C-l but only if file changed and theme changed dark<->light --- vis/.config/vis/visrc.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) 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)