awesome-wm - Awesome-wm 中鼠标触摸屏幕边缘时执行命令

标签 awesome-wm

我是在 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/

相关文章:

lua - 很棒的 wm 中的 cpu 温度小部件

lua - 每个标签列表项都有不同的背景颜色 AwesomeWM

awesome-wm - Awesome WM - 应用程序的全屏模式而不占用整个屏幕

screen - 在 Awesome WM 中打开事件/选定屏幕的程序

window-management - 如何在磁贴布局中使用箭头键在 Awesome WM 中导航打开的程序?

PhpStorm 自动完成/对话框在 Awesome WM/Xmonad 中消失

linux - 真棒 WM : terminal window doesn't take full space

c++ - 样本 SDL 程序给出一个空窗口

menu - 在 Awesome WM 菜单中切换用户

youtube - 在 Awesome 3.5 中最大化 youtube 视频时如何删除标题栏?