summaryrefslogtreecommitdiff
path: root/github-contributions-widget
diff options
context:
space:
mode:
Diffstat (limited to 'github-contributions-widget')
-rw-r--r--github-contributions-widget/README.md37
-rw-r--r--github-contributions-widget/github-contributions-widget.lua36
-rw-r--r--github-contributions-widget/screenshots/Thomashighbaugh.pngbin0 -> 384 bytes
-rw-r--r--github-contributions-widget/screenshots/classic.pngbin0 -> 494 bytes
-rw-r--r--github-contributions-widget/screenshots/dracula.pngbin0 -> 497 bytes
-rw-r--r--github-contributions-widget/screenshots/leftpad.pngbin0 -> 409 bytes
-rw-r--r--github-contributions-widget/screenshots/pink.pngbin0 -> 409 bytes
-rw-r--r--github-contributions-widget/screenshots/screenshot.jpg (renamed from github-contributions-widget/screenshot.jpg)bin14613 -> 14613 bytes
-rw-r--r--github-contributions-widget/screenshots/screenshot1.jpg (renamed from github-contributions-widget/screenshot1.jpg)bin10879 -> 10879 bytes
-rw-r--r--github-contributions-widget/screenshots/screenshot2.jpg (renamed from github-contributions-widget/screenshot2.jpg)bin6164 -> 6164 bytes
-rw-r--r--github-contributions-widget/screenshots/standard.pngbin0 -> 408 bytes
-rw-r--r--github-contributions-widget/screenshots/teal.pngbin0 -> 409 bytes
-rw-r--r--github-contributions-widget/themes.lua46
13 files changed, 100 insertions, 19 deletions
diff --git a/github-contributions-widget/README.md b/github-contributions-widget/README.md
index b7f6b93..7d02008 100644
--- a/github-contributions-widget/README.md
+++ b/github-contributions-widget/README.md
@@ -1,8 +1,12 @@
# Github Contributions Widget
-Shows the contribution graph, similar to the one on the github profile page:
+The widget is inspired by the https://github-contributions.now.sh/ and relies on it's API.
-![screenshot](./screenshot.jpg)
+It shows the contribution graph, similar to the one on the github profile page: ![screenshot](./screenshots/screenshot.jpg)
+
+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:
+
+![](./screenshots/Thomashighbaugh.png)
## Customization
@@ -10,20 +14,37 @@ It is possible to customize the widget by providing a table with all or some of
| Name | Default | Description |
|---|---|---|
-| `username` | 'streetturtle' | Username |
+| `username` | `streetturtle` | GitHub username |
| `days` | `365` | Number of days in the past, more days - wider the widget |
-| `empty_color` | `beautiful.bg_normal` | Color of the days with no contributions |
+| `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
-Few more screenshots:
+Following themes are available:
+
+| Theme name | Preview |
+|---|---|
+| standard | ![standard](./screenshots/standard.png) |
+| classic | ![classic](./screenshots/classic.png) |
+| teal | ![teal](./screenshots/teal.png) |
+| leftpad | ![leftpad](./screenshots/leftpad.png) |
+| dracula | ![dracula](./screenshots/dracula.png) |
+| pink | ![pink](./screenshots/pink.png) |
+
+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:
-![screenshot1](./screenshot1.jpg)
+![screenshot1](./screenshots/screenshot1.jpg)
365 days, no border:
-![screenshot2](./screenshot2.jpg)
-
+![screenshot2](./screenshots/screenshot2.jpg)
## Installation
diff --git a/github-contributions-widget/github-contributions-widget.lua b/github-contributions-widget/github-contributions-widget.lua
index 3025d17..b462299 100644
--- a/github-contributions-widget/github-contributions-widget.lua
+++ b/github-contributions-widget/github-contributions-widget.lua
@@ -9,12 +9,11 @@
-------------------------------------------------
local awful = require("awful")
+local naughty = require("naughty")
local wibox = require("wibox")
-local beautiful = require("beautiful")
+local widget_themes = require("awesome-wm-widgets.github-contributions-widget.themes")
local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.now.sh/api/v1/%s | jq -r '[.contributions[] | select ( .date | strptime(\"%%Y-%%m-%%d\") | mktime < now)][:%s]| .[].color'"]]
--- in case github-contributions.now.sh stops working contributions can be scrapped from the github.com with the command below. Note that the order is reversed.
-local GET_CONTRIBUTIONS_CMD_FALLBACK = [[bash -c "curl -s https://github.com/users/%s/contributions | grep -o '\" fill=\"\#[0-9a-fA-F]\{6\}\" da' | grep -o '\#[0-9a-fA-F]\{6\}'"]]
local github_contributions_widget = wibox.widget{
reflection = {
@@ -24,24 +23,39 @@ local github_contributions_widget = wibox.widget{
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(args)
local args = args or {}
local username = args.username or 'streetturtle'
local days = args.days or 365
- local empty_color = args.empty_color or beautiful.bg_normal
+ 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 hex2rgb(hex)
- if hex == '#ebedf0' then hex = empty_color end
- hex = tostring(hex):gsub("#","")
- return tonumber("0x" .. hex:sub(1, 2)),
- tonumber("0x" .. hex:sub(3, 4)),
- tonumber("0x" .. hex:sub(5, 6))
+ if color_of_empty_cells ~= nil and hex == widget_themes[theme]['color_calendar_graph_day_bg'] 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)
@@ -64,7 +78,7 @@ local function worker(args)
local row = {layout = wibox.layout.fixed.horizontal}
local a = 5 - os.date('%w')
for i = 0, a do
- table.insert(col, get_square('#ebedf0'))
+ table.insert(col, get_square(color_of_empty_cells))
end
local update_widget = function(widget, stdout, _, _, _)
@@ -73,7 +87,7 @@ local function worker(args)
table.insert(row, col)
col = {layout = wibox.layout.fixed.vertical}
end
- table.insert(col, get_square(colors))
+ table.insert(col, get_square(widget_themes[theme][colors:match('var%(%-%-(.*)%)'):gsub('-', '_')]))
a = a + 1
end
github_contributions_widget:setup(
diff --git a/github-contributions-widget/screenshots/Thomashighbaugh.png b/github-contributions-widget/screenshots/Thomashighbaugh.png
new file mode 100644
index 0000000..b31245b
--- /dev/null
+++ b/github-contributions-widget/screenshots/Thomashighbaugh.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/classic.png b/github-contributions-widget/screenshots/classic.png
new file mode 100644
index 0000000..4652140
--- /dev/null
+++ b/github-contributions-widget/screenshots/classic.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/dracula.png b/github-contributions-widget/screenshots/dracula.png
new file mode 100644
index 0000000..65fb769
--- /dev/null
+++ b/github-contributions-widget/screenshots/dracula.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/leftpad.png b/github-contributions-widget/screenshots/leftpad.png
new file mode 100644
index 0000000..19e4f64
--- /dev/null
+++ b/github-contributions-widget/screenshots/leftpad.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/pink.png b/github-contributions-widget/screenshots/pink.png
new file mode 100644
index 0000000..2fb7bc6
--- /dev/null
+++ b/github-contributions-widget/screenshots/pink.png
Binary files differ
diff --git a/github-contributions-widget/screenshot.jpg b/github-contributions-widget/screenshots/screenshot.jpg
index 15ad456..15ad456 100644
--- a/github-contributions-widget/screenshot.jpg
+++ b/github-contributions-widget/screenshots/screenshot.jpg
Binary files differ
diff --git a/github-contributions-widget/screenshot1.jpg b/github-contributions-widget/screenshots/screenshot1.jpg
index d1eeb44..d1eeb44 100644
--- a/github-contributions-widget/screenshot1.jpg
+++ b/github-contributions-widget/screenshots/screenshot1.jpg
Binary files differ
diff --git a/github-contributions-widget/screenshot2.jpg b/github-contributions-widget/screenshots/screenshot2.jpg
index 5ce47f2..5ce47f2 100644
--- a/github-contributions-widget/screenshot2.jpg
+++ b/github-contributions-widget/screenshots/screenshot2.jpg
Binary files differ
diff --git a/github-contributions-widget/screenshots/standard.png b/github-contributions-widget/screenshots/standard.png
new file mode 100644
index 0000000..e10479a
--- /dev/null
+++ b/github-contributions-widget/screenshots/standard.png
Binary files differ
diff --git a/github-contributions-widget/screenshots/teal.png b/github-contributions-widget/screenshots/teal.png
new file mode 100644
index 0000000..f10de7a
--- /dev/null
+++ b/github-contributions-widget/screenshots/teal.png
Binary files differ
diff --git a/github-contributions-widget/themes.lua b/github-contributions-widget/themes.lua
new file mode 100644
index 0000000..a263d1c
--- /dev/null
+++ b/github-contributions-widget/themes.lua
@@ -0,0 +1,46 @@
+local themes = {
+ standard = {
+ color_calendar_graph_day_L4_bg = '#216e39',
+ color_calendar_graph_day_L3_bg = '#30a14e',
+ color_calendar_graph_day_L2_bg = '#40c463',
+ color_calendar_graph_day_L1_bg = '#9be9a8',
+ color_calendar_graph_day_bg = '#ebedf0'
+ },
+ classic = {
+ color_calendar_graph_day_L4_bg = '#196127',
+ color_calendar_graph_day_L3_bg = '#239a3b',
+ color_calendar_graph_day_L2_bg = '#7bc96f',
+ color_calendar_graph_day_L1_bg = '#c6e48b',
+ color_calendar_graph_day_bg = '#ebedf0',
+ },
+ teal = {
+ color_calendar_graph_day_L4_bg = '#458B74',
+ color_calendar_graph_day_L3_bg = '#66CDAA',
+ color_calendar_graph_day_L2_bg = '#76EEC6',
+ color_calendar_graph_day_L1_bg = '#7FFFD4',
+ color_calendar_graph_day_bg = '#ebedf0',
+ },
+ leftpad = {
+ color_calendar_graph_day_L4_bg = '#F6F6F6',
+ color_calendar_graph_day_L3_bg = '#DDDDDD',
+ color_calendar_graph_day_L2_bg = '#A5A5A5',
+ color_calendar_graph_day_L1_bg = '#646464',
+ color_calendar_graph_day_bg = '#2F2F2F',
+ },
+ dracula = {
+ color_calendar_graph_day_L4_bg = '#ff79c6',
+ color_calendar_graph_day_L3_bg = '#bd93f9',
+ color_calendar_graph_day_L2_bg = '#6272a4',
+ color_calendar_graph_day_L1_bg = '#44475a',
+ color_calendar_graph_day_bg = '#282a36'
+ },
+ pink = {
+ color_calendar_graph_day_L4_bg = '#61185f',
+ color_calendar_graph_day_L3_bg = '#a74aa8',
+ color_calendar_graph_day_L2_bg = '#ca5bcc',
+ color_calendar_graph_day_L1_bg = '#e48bdc',
+ color_calendar_graph_day_bg = '#ebedf0',
+ }
+}
+
+return themes \ No newline at end of file