From fdfada2f02d9f09635c4c2e8f64d8ef46eb701c5 Mon Sep 17 00:00:00 2001 From: Manu Cornet Date: Tue, 14 Dec 2021 07:58:43 +0000 Subject: [PATCH] Show notifications --- awesome-workspace-grid.lua | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/awesome-workspace-grid.lua b/awesome-workspace-grid.lua index eb0a747..e744b5e 100644 --- a/awesome-workspace-grid.lua +++ b/awesome-workspace-grid.lua @@ -1,4 +1,31 @@ local awful = require("awful") +local naughty = require("naughty") + +function on_tag_selected(t) + if t.screen == nil then + return + end + -- Only need to do anything on the focused screen. + if t.screen.index ~= awful.screen.focused().index then + return + end + if t.selected == false then + -- This is the tag we are leaving + return + end + for i = 1, screen.count() do + s = screen[i] + notification = naughty.notify({ + position = "top_middle", + preset = naughty.config.presets.normal, + replaces_id = s.workspace_notification_id, + screen = i, + text = t.name, + timeout = 1, + }) + s.workspace_notification_id = notification.id + end +end local workspace_grid = {} @@ -7,9 +34,17 @@ function workspace_grid:new(args) end function workspace_grid:init(args) - self.rows = args.rows - self.columns = args.columns - return self + self.rows = args.rows + self.columns = args.columns + + if args.visual then + awful.screen.connect_for_each_screen(function(s) + s.workspace_notification_id = nil + end) + tag.connect_signal("property::selected", on_tag_selected) + end + + return self end function workspace_grid:navigate(direction)