-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlayoutnotification.lua
57 lines (51 loc) · 1.9 KB
/
layoutnotification.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local awful = require("awful")
local beautiful = require("beautiful")
local naughty = require("naughty")
local layoutNotificationInScreen = {}
local layoutNotifiedInScreen = {}
local notifyLayoutIcon = function(t)
local screen = t.screen
if not screen then return end
local layout = awful.layout.get(screen)
if layoutNotifiedInScreen[screen.index] == layout or not screen.selected_tag then
return
end
layoutNotificationInScreen[screen.index] = naughty.notify{
icon = beautiful["layout_"..awful.layout.getname(layout)],
border_width = 0,
margin = 0,
timeout = 1,
screen = screen,
ontop = true,
ignore_suspend = true,
replaces_id = layoutNotificationInScreen[screen.index],
}.id
layoutNotifiedInScreen[screen.index] = layout
end
-- Whenever a tag is selected or unselected, try to notify
tag.connect_signal("property::selected", notifyLayoutIcon)
-- Whenever a tag layour changes, notify
tag.connect_signal("property::layout", notifyLayoutIcon)
for s in screen do
notifyLayoutIcon(s.selected_tag)
end
local ncolmasterNotificationInScreen = {}
local notifyNcolNmaster = function(t)
local screen = t.screen
local text = string.format("N Master: %d\nN Column: %d", t.master_count, t.column_count)
local notification = naughty.getById(ncolmasterNotificationInScreen[screen.index])
if notification then
naughty.replace_text(notification, nil, text)
naughty.reset_timeout(notification, 0)
else
ncolmasterNotificationInScreen[screen.index] = naughty.notify{
text = text,
timeout = 3,
screen = screen,
ignore_suspend = true,
replaces_id = ncolmasterNotificationInScreen[screen.index],
}.id
end
end
tag.connect_signal("property::master_count", notifyNcolNmaster)
tag.connect_signal("property::column_count", notifyNcolNmaster)