aboutsummaryrefslogtreecommitdiff
path: root/content/resources/mymenu.lua
blob: b3e5be49eca38fa4feac654f385334489c2f3e8e (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
66
67
-- Menu d'application

local awbeautiful = require("beautiful")
local awful = require("awful")
local capi     = {
    screen     = screen,
}

local function getStickyIcon(client)
    if client.sticky then
        return awbeautiful.get().titlebar_sticky_button_focus_active
    end
    return awbeautiful.get().titlebar_sticky_button_focus_inactive
end

local function getOnTopIcon(client)
    if client.ontop then
        return awbeautiful.get().titlebar_ontop_button_focus_active
    end
    return awbeautiful.get().titlebar_ontop_button_focus_inactive
end

function newAppMenu(client)
    local data = {}
    local myAppMenu = {}

    local args = {}
    args.keygrabber = true

    -- Insert the ontop entry
    -- When onTop is selelected, set in floating mode too
   table.insert(myAppMenu, {"On Top", function()
        -- We do not use floating.togle() but syncronize the floating on top value
        awful.client.floating.set( client, not client.ontop ) 
        client.ontop = not client.ontop
    end , getOnTopIcon(client)}  )

    -- Insert the Sticky entry
   table.insert(myAppMenu, {"Sticky", function() client.sticky = not client.sticky end , getStickyIcon(client)}  )

    -- Insert the Hide entry
    if not client.minimized then
        table.insert(myAppMenu, {"Minimize", function() client.minimized = true end } )
    end
    table.insert(myAppMenu, {"Close", function() client:kill() end, awbeautiful.get().titlebar_close_button_focus } )

    -- Add the move to tag entry
    local moveToTag = {}
    local tags = capi.screen[1]:tags()
    for i = 1, #tags do
        -- We do not show the curent client tags
        local isInTag = false
        local clientTag = tags[i]:clients()
        for j = 1, #clientTag do
            isInTag = isInTag or clientTag[j] == client
        end
        if not isInTag then
            table.insert(moveToTag, {tags[i].name, function() awful.client.movetotag(tags[i], client) end } )
        end
    end
    table.insert(myAppMenu, {"Move To", moveToTag } )

    data.menu = awful.menu.new( { items = myAppMenu} )
    data.menu:show(args)

    return data
end