awesomewm-micky/init.lua

70 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
2021-06-04 08:57:52 +02:00
local micky = 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()
2021-06-04 08:57:52 +02:00
mouse.coords({
x = cgeometry.x + cgeometry.width / 2,
y = cgeometry.y + cgeometry.height / 2
})
2021-05-29 06:01:09 +02:00
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
2021-06-04 08:57:52 +02:00
micky() return false
2021-06-03 15:28:23 +02:00
end
--+ nothing under the mouse, move directly
if focused_client ~= current_client then
2021-06-04 08:57:52 +02:00
micky() return false
2021-06-03 15:28:23 +02:00
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
2021-06-04 08:57:52 +02:00
micky()
2021-06-03 15:28:23 +02:00
end
2021-06-04 08:57:52 +02:00
--+ no need for the callback here.
2021-06-03 15:28:23 +02:00
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
2021-06-04 08:57:52 +02:00
return micky
2021-05-29 06:01:09 +02:00
2021-06-04 08:57:52 +02:00
--+ can also manually invoke the function through
--> shortcuts, but this is not necessary with this new
--> version.
2021-05-29 06:01:09 +02:00
-- 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})