Dump nixos config after scrubing
|
|
@ -0,0 +1,63 @@
|
|||
# Github Contributions Widget
|
||||
|
||||
The widget is inspired by the https://github-contributions.now.sh/ and relies on it's API.
|
||||
|
||||
It shows the contribution graph, similar to the one on the github profile page: 
|
||||
|
||||
You might wonder what could be the reason to have your github's contributions in front of you all day long? The more you contribute, the nicer widget looks! Check out [Thomashighbaugh](https://github.com/Thomashighbaugh)'s graph:
|
||||
|
||||

|
||||
|
||||
## Customization
|
||||
|
||||
It is possible to customize the widget by providing a table with all or some of the following config parameters:
|
||||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `username` | `streetturtle` | GitHub username |
|
||||
| `days` | 365 | Number of days in the past, more days - wider the widget |
|
||||
| `color_of_empty_cells` | Theme's default | Color of the days with no contributions |
|
||||
| `with_border` | true | Should the graph contains border or not |
|
||||
| `margin_top` | 1 | Top margin |
|
||||
| `theme` | `standard` | Color theme of the graph, see below |
|
||||
|
||||
_Note:_ widget height is 21px (7 rows of 3x3 cells). So it would look nice on the wibar of 22-24px height.
|
||||
|
||||
### Themes
|
||||
|
||||
Following themes are available:
|
||||
|
||||
| Theme name | Preview |
|
||||
|---|---|
|
||||
| standard |  |
|
||||
| classic |  |
|
||||
| teal |  |
|
||||
| leftpad |  |
|
||||
| dracula |  |
|
||||
| pink |  |
|
||||
|
||||
To add a new theme, simply add a new entry in `themes` table (themes.lua) with the colors of your theme.
|
||||
|
||||
### Screenshots
|
||||
|
||||
1000 days, with border:
|
||||

|
||||
|
||||
365 days, no border:
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Clone/download repo under **~/.config/awesome** and use widget in **rc.lua**:
|
||||
|
||||
```lua
|
||||
local github_contributions_widget = require("awesome-wm-widgets.github-contributions-widget.github-contributions-widget")
|
||||
...
|
||||
s.mytasklist, -- Middle widget
|
||||
{ -- Right widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
...
|
||||
-- default
|
||||
github_contributions_widget({username = '<your username>'}),
|
||||
...
|
||||
```
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
-------------------------------------------------
|
||||
-- Github Contributions Widget for Awesome Window Manager
|
||||
-- Shows the contributions graph
|
||||
-- More details could be found here:
|
||||
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/github-contributions-widget
|
||||
|
||||
-- @author Pavel Makhov
|
||||
-- @copyright 2020 Pavel Makhov
|
||||
-------------------------------------------------
|
||||
|
||||
local awful = require("awful")
|
||||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
local gears = require("gears")
|
||||
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]]
|
||||
.. [[ | jq -r '[.contributions[] ]]
|
||||
.. [[ | select ( .date | strptime(\"%%Y-%%m-%%d\") | mktime < now)][:%s]| .[].intensity'"]]
|
||||
|
||||
local github_contributions_widget = wibox.widget{
|
||||
reflection = {
|
||||
horizontal = true,
|
||||
vertical = true,
|
||||
},
|
||||
widget = wibox.container.mirror
|
||||
}
|
||||
|
||||
local function show_warning(message)
|
||||
naughty.notify{
|
||||
preset = naughty.config.presets.critical,
|
||||
title = 'Github Contributions Widget',
|
||||
text = message}
|
||||
end
|
||||
|
||||
local function worker(user_args)
|
||||
|
||||
local args = user_args or {}
|
||||
local username = args.username or 'streetturtle'
|
||||
local days = args.days or 365
|
||||
local color_of_empty_cells = args.color_of_empty_cells
|
||||
local with_border = args.with_border
|
||||
local margin_top = args.margin_top or 1
|
||||
local theme = args.theme or 'standard'
|
||||
|
||||
if widget_themes[theme] == nil then
|
||||
show_warning('Theme ' .. theme .. ' does not exist')
|
||||
theme = 'standard'
|
||||
end
|
||||
|
||||
if with_border == nil then with_border = true end
|
||||
|
||||
local function get_square(color)
|
||||
if color_of_empty_cells ~= nil and color == widget_themes[theme][0] then
|
||||
color = color_of_empty_cells
|
||||
end
|
||||
|
||||
return wibox.widget{
|
||||
fit = function()
|
||||
return 3, 3
|
||||
end,
|
||||
draw = function(_, _, cr, _, _)
|
||||
cr:set_source(gears.color(color))
|
||||
cr:rectangle(0, 0, with_border and 2 or 3, with_border and 2 or 3)
|
||||
cr:fill()
|
||||
end,
|
||||
layout = wibox.widget.base.make_widget
|
||||
}
|
||||
end
|
||||
|
||||
local col = {layout = wibox.layout.fixed.vertical}
|
||||
local row = {layout = wibox.layout.fixed.horizontal}
|
||||
local day_idx = 5 - os.date('%w')
|
||||
for _ = 0, day_idx do
|
||||
table.insert(col, get_square(color_of_empty_cells))
|
||||
end
|
||||
|
||||
local update_widget = function(_, stdout, _, _, _)
|
||||
for intensity in stdout:gmatch("[^\r\n]+") do
|
||||
if day_idx %7 == 0 then
|
||||
table.insert(row, col)
|
||||
col = {layout = wibox.layout.fixed.vertical}
|
||||
end
|
||||
table.insert(col, get_square(widget_themes[theme][tonumber(intensity)]))
|
||||
day_idx = day_idx + 1
|
||||
end
|
||||
github_contributions_widget:setup(
|
||||
{
|
||||
row,
|
||||
top = margin_top,
|
||||
layout = wibox.container.margin
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
awful.spawn.easy_async(string.format(GET_CONTRIBUTIONS_CMD, username, days),
|
||||
function(stdout)
|
||||
update_widget(github_contributions_widget, stdout)
|
||||
end)
|
||||
|
||||
return github_contributions_widget
|
||||
end
|
||||
|
||||
return setmetatable(github_contributions_widget, { __call = function(_, ...) return worker(...) end })
|
||||
|
After Width: | Height: | Size: 384 B |
|
After Width: | Height: | Size: 494 B |
|
After Width: | Height: | Size: 497 B |
|
After Width: | Height: | Size: 409 B |
|
After Width: | Height: | Size: 409 B |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 6 KiB |
|
After Width: | Height: | Size: 408 B |
|
After Width: | Height: | Size: 409 B |
|
|
@ -0,0 +1,46 @@
|
|||
local themes = {
|
||||
standard = {
|
||||
[4] = '#216e39',
|
||||
[3] = '#30a14e',
|
||||
[2] = '#40c463',
|
||||
[1] = '#9be9a8',
|
||||
[0] = '#ebedf0'
|
||||
},
|
||||
classic = {
|
||||
[4] = '#196127',
|
||||
[3] = '#239a3b',
|
||||
[2] = '#7bc96f',
|
||||
[1] = '#c6e48b',
|
||||
[0] = '#ebedf0',
|
||||
},
|
||||
teal = {
|
||||
[4] = '#458B74',
|
||||
[3] = '#66CDAA',
|
||||
[2] = '#76EEC6',
|
||||
[1] = '#7FFFD4',
|
||||
[0] = '#ebedf0',
|
||||
},
|
||||
leftpad = {
|
||||
[4] = '#F6F6F6',
|
||||
[3] = '#DDDDDD',
|
||||
[2] = '#A5A5A5',
|
||||
[1] = '#646464',
|
||||
[0] = '#2F2F2F',
|
||||
},
|
||||
dracula = {
|
||||
[4] = '#ff79c6',
|
||||
[3] = '#bd93f9',
|
||||
[2] = '#6272a4',
|
||||
[1] = '#44475a',
|
||||
[0] = '#282a36'
|
||||
},
|
||||
pink = {
|
||||
[4] = '#61185f',
|
||||
[3] = '#a74aa8',
|
||||
[2] = '#ca5bcc',
|
||||
[1] = '#e48bdc',
|
||||
[0] = '#ebedf0',
|
||||
}
|
||||
}
|
||||
|
||||
return themes
|
||||