some shit
This commit is contained in:
@ -1,30 +1,36 @@
|
||||
-- see if the file exists
|
||||
local function file_exists(file)
|
||||
local f = io.open(file, "rb")
|
||||
if f then f:close() end
|
||||
if f then
|
||||
f:close()
|
||||
end
|
||||
return f ~= nil
|
||||
end
|
||||
|
||||
-- get all lines from a file, returns an empty
|
||||
-- list/table if the file does not exist
|
||||
local function line_from(file)
|
||||
if not file_exists(file) then return "" end
|
||||
if not file_exists(file) then
|
||||
return ""
|
||||
end
|
||||
local f = io.open(file) -- 'r' is unnecessary because it's a default value.
|
||||
if f == nil then return "" end
|
||||
if f == nil then
|
||||
return ""
|
||||
end
|
||||
local line = f:read() -- '*l' is unnecessary because it's a default value.
|
||||
f:close()
|
||||
return line;
|
||||
return line
|
||||
end
|
||||
|
||||
local filePath = os.getenv("HOME") .. "/.cache/dark-mode";
|
||||
local filePath = os.getenv("HOME") .. "/.cache/dark-mode"
|
||||
local function updateTheme()
|
||||
local line = line_from(filePath);
|
||||
local line = line_from(filePath)
|
||||
if line then
|
||||
local light = string.find(line, "light");
|
||||
local light = string.find(line, "light")
|
||||
if light then
|
||||
vim.cmd("colorscheme dayfox")
|
||||
-- vim.cmd("colorscheme dayfox")
|
||||
else
|
||||
vim.cmd("colorscheme nightfox")
|
||||
-- vim.cmd("colorscheme nightfox")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user