aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/signals/awesome.lua
blob: 4ed3d32e59e6b0a3276e446aa8897d17ebb8b7c0 (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
-- 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)