diff options
author | Pavel Makhov <pmakhov@theoctavegroup.com> | 2019-09-23 21:05:36 -0400 |
---|---|---|
committer | Pavel Makhov <pmakhov@theoctavegroup.com> | 2019-09-23 21:05:36 -0400 |
commit | d014b9a259898f7c2f8dcdcd1ccf4cd7b9b13432 (patch) | |
tree | 7dd26fa8da6d62b0aaa48764aff6f167df95cf78 | |
parent | 405e8b5d12814e3ff411e2447766cfb58e56daa0 (diff) |
add a notification when new review is assigned
-rw-r--r-- | gerrit-widget/Gerrit_icon.svg | 8 | ||||
-rw-r--r-- | gerrit-widget/gerrit.lua | 17 |
2 files changed, 24 insertions, 1 deletions
diff --git a/gerrit-widget/Gerrit_icon.svg b/gerrit-widget/Gerrit_icon.svg new file mode 100644 index 0000000..4ac5652 --- /dev/null +++ b/gerrit-widget/Gerrit_icon.svg @@ -0,0 +1,8 @@ +<svg width="52" height="52" xmlns="http://www.w3.org/2000/svg"> +<rect ry="4" rx="4" height="40" width="40" y="0" x="0" fill="#ffaaaa"/> +<rect ry="4" rx="4" height="40" width="40" y="12" x="12" fill="#aaffaa"/> +<path d="m18,22l12,0l0,4l-12,0l0,-4z" fill="#ff0000"/> +<path d="m34,22l12,0l0,4l-12,0l0,-4z" fill="#ff0000"/> +<path d="m18,36l4,0l0,-4l4,0l0,4l4,0l0,4l-4,0l0,4l-4,0l0,-4l-4,0l0,-4z" fill="#008000"/> +<path d="m34,36l4,0l0,-4l4,0l0,4l4,0l0,4l-4,0l0,4l-4,0l0,-4l-4,0l0,-4z" fill="#008000"/> +</svg>
\ No newline at end of file diff --git a/gerrit-widget/gerrit.lua b/gerrit-widget/gerrit.lua index a2b5fe6..10e839f 100644 --- a/gerrit-widget/gerrit.lua +++ b/gerrit-widget/gerrit.lua @@ -31,6 +31,8 @@ local function worker(args) local reviews local notification_text + local current_number_of_reviews + local previous_number_of_reviews = 0 gerrit_widget = wibox.widget{ widget = wibox.widget.textbox @@ -49,7 +51,20 @@ local function worker(args) local update_graphic = function(widget, stdout, _, _, _) reviews = json.decode(stdout) - widget.text = rawlen(reviews) + + current_number_of_reviews = rawlen(reviews) + + if current_number_of_reviews > previous_number_of_reviews then + naughty.notify{ + icon = os.getenv("HOME") ..'/.config/awesome/awesome-wm-widgets/gerrit-widget/Gerrit_icon.svg', + title = 'New Incoming Review', + text = reviews[1].project .. '\n' .. get_name_by_id(reviews[1].owner._account_id) .. reviews[1].subject ..'\n', + run = function() spawn.with_shell("google-chrome https://" .. host .. '/' .. reviews[1]._number) end + } + end + + previous_number_of_reviews = current_number_of_reviews + widget.text = current_number_of_reviews notification_text = '' for _, review in ipairs(reviews) do |