commit 1b477f591459312553c043a14e87ace24fe96e35 Author: anakha Date: Sat May 29 00:01:09 2021 -0400 initial diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd72254 --- /dev/null +++ b/README.md @@ -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') +``` + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..f6a7a14 --- /dev/null +++ b/init.lua @@ -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),