[github-contributions] color management
This commit is contained in:
parent
1437626e90
commit
f3d1b82fdf
|
@ -11,6 +11,7 @@
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
local gears = require("gears")
|
||||||
local widget_themes = require("awesome-wm-widgets.github-contributions-widget.themes")
|
local widget_themes = require("awesome-wm-widgets.github-contributions-widget.themes")
|
||||||
|
|
||||||
local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.vercel.app/api/v1/%s]]
|
local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.vercel.app/api/v1/%s]]
|
||||||
|
@ -35,7 +36,6 @@ end
|
||||||
local function worker(user_args)
|
local function worker(user_args)
|
||||||
|
|
||||||
local args = user_args or {}
|
local args = user_args or {}
|
||||||
|
|
||||||
local username = args.username or 'streetturtle'
|
local username = args.username or 'streetturtle'
|
||||||
local days = args.days or 365
|
local days = args.days or 365
|
||||||
local color_of_empty_cells = args.color_of_empty_cells
|
local color_of_empty_cells = args.color_of_empty_cells
|
||||||
|
@ -50,25 +50,17 @@ local function worker(user_args)
|
||||||
|
|
||||||
if with_border == nil then with_border = true end
|
if with_border == nil then with_border = true end
|
||||||
|
|
||||||
local function hex2rgb(hex)
|
|
||||||
if color_of_empty_cells ~= nil and hex == widget_themes[theme][0] then
|
|
||||||
hex = color_of_empty_cells
|
|
||||||
end
|
|
||||||
hex = tostring(hex):gsub('#','')
|
|
||||||
return tonumber('0x' .. hex:sub(1, 2)),
|
|
||||||
tonumber('0x' .. hex:sub(3, 4)),
|
|
||||||
tonumber('0x' .. hex:sub(5, 6))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_square(color)
|
local function get_square(color)
|
||||||
local r, g, b = hex2rgb(color)
|
if color_of_empty_cells ~= nil and color == widget_themes[theme][0] then
|
||||||
|
color = color_of_empty_cells
|
||||||
|
end
|
||||||
|
|
||||||
return wibox.widget{
|
return wibox.widget{
|
||||||
fit = function()
|
fit = function()
|
||||||
return 3, 3
|
return 3, 3
|
||||||
end,
|
end,
|
||||||
draw = function(_, _, cr, _, _)
|
draw = function(_, _, cr, _, _)
|
||||||
cr:set_source_rgb(r/255, g/255, b/255)
|
cr:set_source(gears.color(color))
|
||||||
cr:rectangle(0, 0, with_border and 2 or 3, with_border and 2 or 3)
|
cr:rectangle(0, 0, with_border and 2 or 3, with_border and 2 or 3)
|
||||||
cr:fill()
|
cr:fill()
|
||||||
end,
|
end,
|
||||||
|
@ -78,8 +70,8 @@ local function worker(user_args)
|
||||||
|
|
||||||
local col = {layout = wibox.layout.fixed.vertical}
|
local col = {layout = wibox.layout.fixed.vertical}
|
||||||
local row = {layout = wibox.layout.fixed.horizontal}
|
local row = {layout = wibox.layout.fixed.horizontal}
|
||||||
local day_idx = 6 - os.date('%w')
|
local day_idx = 5 - os.date('%w')
|
||||||
for _ = 1, day_idx do
|
for _ = 0, day_idx do
|
||||||
table.insert(col, get_square(color_of_empty_cells))
|
table.insert(col, get_square(color_of_empty_cells))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue