Search code examples
awesome-wm

Execute command when mouse touches screen edge in Awesome-wm


I'm new to doing custom lua for the rc.lua in Awesome and I'm having a bit of trouble working out how to launch something based on the mouse position. This is what I have, so-far, but it's not doing anything.

-- 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()
--

Solution

  • This almost works as intended. For some reason the scratchpad appears on screen 1 the first time and does not center vertically properly (this problem only occurs with a horizontal position of "right", I assume it's a problem with scratchpad), for me, but it should work for people who do not have a multi-monitor setup or for launching other commands of your choice.

    -- 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()
    --