2

I am using a clipboard manager and I would like to see it appear just under the mouse when I press a shortcut key.

I have written different rules for awesome wm, I see how to focus the good client, how to make it floating, how to make it appear at a fixed position..

I found this entry in the Awesome FAQ.

However, I don't see how to use this tip to create a rule.

Any hints ?

| improve this question | | | | |
3

For global use by keyword

at the end of your rc.lua you have the function client.add_signal(... , inside this function you have to set the last line of the FAQ, to enable it for only particular applications I included a new variable at the beginning of rc.lua `

local undermouse = false

than the part of the FAQ:

client.add_signal("manage", function (c, startup)
    -- Add a titlebar
    -- awful.titlebar.add(c, { modkey = modkey })

    -- Enable sloppy focus
    c:add_signal("mouse::enter", function(c)
        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
        and awful.client.focus.filter(c) then
            client.focus = c
        end
    end)

    if not startup then
        -- Set the windows at the slave,
        -- i.e. put it at the end of others instead of setting it master.
        -- awful.client.setslave(c)

        -- Put windows in a smart way, only if they does not set an initial position.
        if not c.size_hints.user_position and not c.size_hints.program_position then
            awful.placement.no_overlap(c)
            awful.placement.no_offscreen(c)
=>          if underMouse == true then
=>              awful.placement.under_mouse(c)
=>              underMouse = false
=>          end
        end
    end
end)

to use this option I created the next code for my calculater key:

globalkeys = awful.util.table.join(
    awful.key({                   }, "#148", function () 
        underMouse = true 
        awful.util.spawn(calculator) 
    end),
)

As a rule for 1 application

as found by yourself after testing my solution, but added to this answer for use for other people:

{ rule = { class = "Gnome-calculator",  },
    properties = { 
        floating = true,
        callback = function(c) awful.placement.under_mouse(c) end,
    },
},
| improve this answer | | | | |
  • @mperrin the down vote (not by me) is probably because I gave the solution and you give the solved at yourself for an answer that should be a comment to my answer. – Gert Pellin Jul 30 '15 at 13:59
  • 1
    Ok, sorry for that, pretty new here. Your answer helped me a lot, but I thought that it didn't answer clearly to the question which was "how to write a rule...", that's why I didn't mark your answer as the accepted solution, but give it a up vote. – mperrin Jul 30 '15 at 18:16
0

Many thanks for your answer, and the highlight of the awful.placement.under_mouse(c) function.

Finally, writing the rule was really easy :

 { rule = { class = "Gnome-calculator",  },
    properties = { 
        floating = true,
        callback = function(c) awful.placement.under_mouse(c) end,
    },
},
| improve this answer | | | | |
  • Don't understand why this has been down voted. – mperrin Jul 30 '15 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.