Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

wezterm/bugabinga/theme.lua

Raw
local wez = require 'wezterm'
local nugu = require 'bugabinga.nugu'

-- wezterm.gui is not available to the mux server, so take care to
-- do something reasonable when this config is evaluated by the mux
local get_nugu_mode = function ()
  local file = io.open( wez.home_dir .. '/.cache/nugu/mode', 'r' )
  if not file then return nil end
  local mode = file:read '*l'
  file:close()
  if mode == 'dark' or mode == 'light' then return mode end
  return nil
end

local get_appearance = function ()
  local mode = get_nugu_mode()
  if mode == 'dark' then return 'Dark' end
  if mode == 'light' then return 'Light' end
  if wez.gui then return wez.gui.get_appearance() end
  return 'Dark'
end

local scheme_for_appearance = function ( appearance )
  if appearance:find( 'Dark', 1, true ) then return 'nugu-dark' end
  return 'nugu-light'
end

return function ( cfg )
  ---@cast cfg Config
  local current_scheme = scheme_for_appearance( get_appearance() )
  cfg.color_scheme = current_scheme

  -- Set color schemes from nugu
  cfg.color_schemes = nugu.schemes

  -- Apply nugu window frame styling
  nugu.apply_window_frame( cfg, current_scheme )
end