awesomewm-micky/init.lua

67 lines
2.0 KiB
Lua
Raw Normal View History

2021-06-03 15:28:23 +02:00
--------------------------------------------------------------> dependencies ;
2021-05-29 06:01:09 +02:00
local gears = require('gears')
2021-06-03 15:28:23 +02:00
-------------------------------------------------------------------> methods ;
2021-05-29 06:01:09 +02:00
local mouser = function ()
2021-06-03 15:28:23 +02:00
gears.timer.weak_start_new(0.05, function()
2021-05-29 06:01:09 +02:00
local c = client.focus
local cgeometry = c:geometry()
mouse.coords({ x = cgeometry.x + cgeometry.width/2 , y = cgeometry.y + cgeometry.height/2 })
end)
2021-06-03 15:28:23 +02:00
end
--+ relocate mouse after slightly waiting for focus to
--> complete. you can adjust the timer if you are on a slow
--> cpu to give more time for the client to appear.
2021-05-29 06:01:09 +02:00
2021-06-03 15:28:23 +02:00
---------------------------------------------------------------------> signal ;
2021-05-29 06:01:09 +02:00
client.connect_signal("focus", function(c)
2021-06-03 15:28:23 +02:00
local focused_client = c
--+ client the focus is going towards
2021-05-29 06:01:09 +02:00
2021-06-03 15:28:23 +02:00
gears.timer.weak_start_new(0.05, function()
local current_client = mouse.current_client
if not current_client then
mouser() return false
end
--+ nothing under the mouse, move directly
if focused_client ~= current_client then
mouser() return false
end
--+ no need to relocate the mouse if already over
--> the client.
end)
--+ mouse.current_client would point to the previous
--> client without the callback.
2021-05-29 06:01:09 +02:00
end)
2021-06-03 14:08:59 +02:00
client.connect_signal("unmanage", function(c)
2021-06-03 15:28:23 +02:00
local current_client = mouse.current_client
2021-06-03 14:08:59 +02:00
2021-06-03 15:28:23 +02:00
if current_client and c ~= current_client then
mouser()
end
--+ no need to relocate the mouse if already over the
--> client.
end)
2021-06-03 14:08:59 +02:00
2021-06-03 15:28:23 +02:00
---------------------------------------------------------------------> export ;
2021-05-29 06:01:09 +02:00
return mouser
-- [*] can also manually invoke the function through
-- shortcuts, but this is not necessary with this new
-- version.
-- awful.key({}, 'XF86HomePage', function ()
-- awful.client.run_or_raise(chromium, matcher('Google-chrome'))
-- mouser()
-- end),
2021-06-03 15:28:23 +02:00
-- naughty.notify({text=current_client.name})
-- naughty.notify({text=focused_client.name})