aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/misc/setup.lua
blob: aeee19adfdbc913f12e27d225e9b6c3d6c6d9ab4 (plain)
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
57
58
59
60
61
62
63
64
65
local naughty = require "naughty"
local beautiful = require "beautiful"
-- local notif_overlay = require "ui.notifs"
local wicked = require "ui.wicked"
local awful = require "awful"
local rubato = require "lib.rubato"
local vars = require "misc.vars"

-- naughty.connect_signal("request::display", function(n)
--     notif_overlay:notify(n)
-- end)

naughty.connect_signal("request::display", function(n)
    naughty.layout.box { 
        notification = n,
        placement = function(d)
            return awful.placement.right(d, {
                margins = beautiful.useless_gap * 2
            })
        end
    }

    -- wicked:.notify(n)
end)

naughty.connect_signal("request::display_error", function(message, startup)
    naughty.notification {
        urgency = "critical",
        title   = "Oops, an error happened"..(startup and " during startup!" or "!"),
        message = message
    }
end)

-- Taken from https://www.reddit.com/r/awesomewm/comments/syjolb/comment/hy0xy35/

awesome.connect_signal('exit', function(reason_restart)
    if not reason_restart then return end

    local file = io.open('/tmp/awesomewm-last-selected-tags', 'w+')

    for s in screen do
        file:write(s.selected_tag.index, '\n') 
    end

    file:close()
end)

awesome.connect_signal('startup', function()
    local file = io.open('/tmp/awesomewm-last-selected-tags', 'r')
    if not file then return end

    local selected_tags = {}

    for line in file:lines() do
        table.insert(selected_tags, tonumber(line))
    end
    
    for s in screen do
        local i = selected_tags[s.index]
        local t = s.tags[i]
        t:view_only()
    end

    file:close()
end)