diff --git a/themer.lua b/themer.lua index 4769cbb..7b2d09c 100755 --- a/themer.lua +++ b/themer.lua @@ -2,11 +2,6 @@ local templater = require 'utils/template' -theme = require 'themes/rose-pine-moon' - -local status = os.execute("mkdir -p ~/.cache/themer.lua/") -if not (status == 0) then return status end - function expect_nil(result) if result then print("Error: "..result) @@ -15,6 +10,21 @@ function expect_nil(result) return nil end +local function read_file(path) + local file = io.open(path, "r") + if not file then return nil end + local content = file:read "*a" -- *a or *all reads the whole file + file:close() + return content +end + +local theme_name_path = os.getenv('HOME').."/.config/themer.lua.theme" +local theme_name = read_file(theme_name_path) +theme = dofile("themes/"..theme_name..".lua") + +local status = os.execute("mkdir -p ~/.cache/themer.lua/") +if not (status == 0) then return status end + function save_config(name, template, params) local file, err = io.open("/home/diablo/.cache/themer.lua/"..name, "w+") if not file then expect_nil(err) end