From 53b2f5caad07178e75a85464f4e6e059685bced7 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sun, 10 Apr 2022 16:24:18 -0300 Subject: [PATCH] Empezar --- modules/foot.lua | 59 +++++++++++++++++++++++++++++++++++++ modules/sway.lua | 8 +++++ themer.lua | 26 ++++++++++++++++ themes/rose-pine-dawn.lua | 19 ++++++++++++ utils/rose-pine-convert.lua | 14 +++++++++ utils/template.lua | 9 ++++++ 6 files changed, 135 insertions(+) create mode 100644 modules/foot.lua create mode 100644 modules/sway.lua create mode 100755 themer.lua create mode 100644 themes/rose-pine-dawn.lua create mode 100644 utils/rose-pine-convert.lua create mode 100644 utils/template.lua diff --git a/modules/foot.lua b/modules/foot.lua new file mode 100644 index 0000000..46284e6 --- /dev/null +++ b/modules/foot.lua @@ -0,0 +1,59 @@ +local scheme = [[ +[colors] +foreground={foreground} +background={background} + +regular0={background} # black (or white in a bright theme) +regular1=7f1010 # red +regular2=009A57 # green +regular3=813e00 # yellow +regular4=0186C7 # blue +regular5=721045 # magenta +regular6=00538b # cyan +regular7={background} # white (or black in a bright theme) + +bright0=e4e4e4 +bright1=ff8686 +bright2=bcd2aa +bright3=989838 +bright4=00AEFF +bright5=8888CC +bright6=4FA8A8 +bright7={foreground} +]] + +if theme.kind == "rose-pine" then + scheme = [[ + [cursor] + color = {inactive} {text} + + [colors] + background = {base} + foreground = {text} + + selection-foreground = {text} + selection-background = {highlight} + + urls = {iris} + + regular0 = {overlay} + regular1 = {love} + regular2 = {pine} + regular3 = {gold} + regular4 = {foam} + regular5 = {iris} + regular6 = {rose} + regular7 = {text} + + bright0 = {subtle} + bright1 = {love} + bright2 = {pine} + bright3 = {gold} + bright4 = {foam} + bright5 = {iris} + bright6 = {rose} + bright7 = {text} + ]] +end + +save_config("foot", scheme, theme) diff --git a/modules/sway.lua b/modules/sway.lua new file mode 100644 index 0000000..7c67424 --- /dev/null +++ b/modules/sway.lua @@ -0,0 +1,8 @@ +save_config("sway-colors", [[ +set $background #{background} +set $backgroundish #{backgroundish} +set $foreground #{foreground} +set $foregroundish #{foregroundish} +set $accent #{accent} +set $accentish #{accentish} +]], theme) \ No newline at end of file diff --git a/themer.lua b/themer.lua new file mode 100755 index 0000000..61d9970 --- /dev/null +++ b/themer.lua @@ -0,0 +1,26 @@ +#!/usr/bin/env lua5.1 + +local templater = require 'utils/template' + +theme = require 'themes/rose-pine-dawn' + +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) + os.exit(1) + end + return nil +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 + file:write(templater(template, params)) + file:close() +end + +require 'modules/sway' +require 'modules/foot' diff --git a/themes/rose-pine-dawn.lua b/themes/rose-pine-dawn.lua new file mode 100644 index 0000000..53999d6 --- /dev/null +++ b/themes/rose-pine-dawn.lua @@ -0,0 +1,19 @@ +local theme = { + base = "faf4ed", + surface = "fffaf3", + overlay = "f2e9de", + inactive = "9893a5", + subtle = "6e6a86", + text = "575279", + love = "b4637a", + gold = "ea9d34", + rose = "d7827e", + pine = "286983", + foam = "56949f", + iris = "907aa9", + highlight = "eee9e6", + highlightInactive = "f2ede9", + highlightOverlay = "e4dfde", + dark = false, +} +return require('utils/rose-pine-convert')(theme) diff --git a/utils/rose-pine-convert.lua b/utils/rose-pine-convert.lua new file mode 100644 index 0000000..00b9f70 --- /dev/null +++ b/utils/rose-pine-convert.lua @@ -0,0 +1,14 @@ +return function (theme) + local new = { + background = theme.base, + backgroundish = theme.overlay, + foreground = theme.text, + foregroundish = theme.subtle, + accent = theme.love, + accentish = theme.rose, + + kind = "rose-pine", + } + for k,v in pairs(theme) do new[k] = v end + return new +end diff --git a/utils/template.lua b/utils/template.lua new file mode 100644 index 0000000..c5a9fca --- /dev/null +++ b/utils/template.lua @@ -0,0 +1,9 @@ +return function (template, params) + local content = string.gsub(template, "{(%w+)}", function (s) + if params[s] == nil then + expect_nil("No variable "..s) + end + return params[s] + end) + return content +end