add a notification when new review is assigned

This commit is contained in:
Pavel Makhov 2019-09-23 21:05:36 -04:00
parent 405e8b5d12
commit d014b9a259
2 changed files with 24 additions and 1 deletions

View file

@ -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>

After

Width:  |  Height:  |  Size: 504 B

View file

@ -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