【问题标题】:Execute command when mouse touches screen edge in Awesome-wm当鼠标在 Awesome-wm 中触摸屏幕边缘时执行命令
【发布时间】:2012-09-19 05:46:23
【问题描述】:

我是在 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()
--

【问题讨论】:

  • 瑞恩,你可以回答你自己的问题。 (只需点击“答案”按钮。)您的答案不会丢失。只需单击“已编辑...”链接并复制您的帖子。发布那个作为答案。

标签: awesome-wm


【解决方案1】:

您可以/应该使用鼠标抓取器,而不是使用计时器,如下所示:

mousegrabber.run(function(mouse)
    if mouse.x > 3196 then
        -- Do your stuff here
    end
    -- Return true, to continue grabbing the mouse
    return true
end)

这种方法的问题在于,您一次只能注册一个鼠标抓取器。所以这是一个完美的解决方案,如果您只需要稍等一下鼠标移动。如果您需要更长的时间,您可以在需要抓取器进行其他操作(主要是客户端调整大小和移动)时停止抓取,并在完成后启动它。

【讨论】:

    【解决方案2】:

    这几乎可以按预期工作。由于某种原因,暂存器第一次出现在屏幕 1 上并且没有正确垂直居中(这个问题只发生在水平位置“正确”的情况下,我认为这是暂存器的问题),对我来说,但它应该适用于人们谁没有多显示器设置或启动您选择的其他命令。

    -- Open todo when mouse hits right screen edge.
    local function todopad()
        scratch.drop("urxvt -e vimpager /home/ryan/to-do", "center", "right", .20, 800, "true", 2)
    end
    
    todo_timer = timer({timeout = 1})
    todo_timer:add_signal("timeout", function()
        if mouse.coords()["x"] >= 3196 then
            todopad()
        end
    end)
    todo_timer:start()
    --
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多