From d014b9a259898f7c2f8dcdcd1ccf4cd7b9b13432 Mon Sep 17 00:00:00 2001 From: Pavel Makhov Date: Mon, 23 Sep 2019 21:05:36 -0400 Subject: [PATCH] add a notification when new review is assigned --- gerrit-widget/Gerrit_icon.svg | 8 ++++++++ gerrit-widget/gerrit.lua | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gerrit-widget/Gerrit_icon.svg 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 @@ + + + + + + + + \ 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