This commit is contained in:
anakha 2021-05-29 00:01:09 -04:00
commit 1b477f5914
2 changed files with 52 additions and 0 deletions

16
README.md Normal file
View File

@ -0,0 +1,16 @@
# awesomewm-mouser
an awesomewm module automatically moves and centers your mouse cursor to the active (focused) window.
### config
in your ~/.config/awesome folder
```
git clone https://github.com/basaran/awesomewm-mouser
```
and then import in your `rc.lua`
```
require('awesomewm-mouser')
```

36
init.lua Normal file
View File

@ -0,0 +1,36 @@
-- [*] ------------------------------------------------------- dependencies -- ;
local gears = require('gears')
-- [*] ------------------------------------------------------------ methods -- ;
local mouser = function ()
gears.timer.weak_start_new(0.1, function()
local c = client.focus
local cgeometry = c:geometry()
mouse.coords({ x = cgeometry.x + cgeometry.width/2 , y = cgeometry.y + cgeometry.height/2 })
end)
end -- [+] relocate mouse after slightly waiting for focus to complete
-- [*] ------------------------------------------------------------- signal -- ;
client.connect_signal("focus", function(c)
local current_client = mouse.current_client
if current_client and c ~= current_client then
mouser()
end -- [+] no need to relocate the mouse if already over the client
end)
-- [*] ------------------------------------------------------------- export -- ;
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),