3

I'm using Awesome Window Manager. I want to show my top bar by pressing mod4 and then hide it when I release. I tired passing "keyup Mod4" to awful.key but it does not work. How can I tell it that I want to trigger an event on keyup?

4 Answers 4

2

Try

`awful.key({ modkey }, "", nil, function () staff here end)`

3rd param is handler for "release" event when passed.

2

I wanted the same thing! After some research I came up with:

  • Use external program to execute echo 'mywibox[1].visible = true' | awesome-client when mod4 is pressed and echo 'mywibox[1].visible = false' | awesome-client when released.
  • Use other key, not modifier, like Menu (near right Ctrl), because for some reason you can't hook up press and release event to mod4 (or it just doesn't work).

Here is my solution (timer is required because pressed key sends events as long as it is pressed):

-- Put it somewhere at the beginning
presswait = { started = false }

-- Put it in key bindings section (globalkeys = within awful.table.join)
awful.key({ }, "Menu", function()
    if presswait.started then
            presswait:stop()
    else
        -- One second to tell if key is released
        presswait = timer({ timeout = 1 })
        presswait:connect_signal("timeout", function()
            presswait:stop()

            -- Key is released
            for i = 1, screen.count() do
                mywibox[i].visible = false
            end
        end)

        -- Key is pressed
        for i = 1, screen.count() do
            mywibox[i].visible = true
        end
    end
    presswait:start()
end)
1

You could connect a signal to the key object:

key.connect_signal("press", function(k)
    -- Analyze k and act accordingly
end)

More about signals here: http://awesome.naquadah.org/wiki/Signals

0

Using the first suggestion from https://stackoverflow.com/a/21837280/2656413 I wrote this python script: https://github.com/grandchild/autohidewibox

What it does is, it runs xinput in the background and parses its output. You could also parse /dev/input/event1 directly in python, but I was lazy.

It then pipes the following lua code to awesome every time the key is pressed or released:

echo 'for i, box in pairs(mywibox) do box.visible = true end' | awesome-client

and

echo 'for i, box in pairs(mywibox) do box.visible = false end' | awesome-client

respectively.

Update:

For awesome 4+ use:

echo "for s in screen do s.mywibox.visible = false end" | awesome-client

or true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.