我是在 Awesome 中为 rc.lua 进行自定义 lua 的新手,在弄清楚如何根据鼠标位置启动某些内容时遇到了一些麻烦。到目前为止,这就是我所拥有的,但它没有做任何事情。
-- Open todo when mouse hits right screen edge.
todo_timer = timer({timeout = 0.1})
todo_timer:add_signal("todopopup", function()
if mouse.coords.x >= 3198 then
scratch.drop("urxvt -e vim /home/ryan/to-do", "center", "right", 0.33, 1, "true")
end
end)
todo_timer:start()
--
最佳答案
您可以/应该使用鼠标抓取器,而不是使用计时器,如下所示:
mousegrabber.run(function(mouse)
if mouse.x > 3196 then
-- Do your stuff here
end
-- Return true, to continue grabbing the mouse
return true
end)
这种方法的问题是,您一次只能注册一个 mousegrabber。因此,如果您只需要短暂监听鼠标移动,那么这是一个完美的解决方案。如果您需要更长的时间,您可以在需要抓取器执行其他操作(主要是客户端调整大小和移动)时停止抓取,并在完成后启动抓取。
关于awesome-wm - Awesome-wm 中鼠标触摸屏幕边缘时执行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12451161/