Search code examples
functionluawindow-managersawesome-wm

How to toggle the titlebar in AwesomeWM?


I am trying to modify my rc.lua file the following way: when I press Mod4+R, AwesomeWM keybinding for running a command, I want Rofi to appear, blur my wallpaper and hide everything from my screen. I only want the Rofi prompt over a blurred wallpaper to be seen.

To achieve this, I have the following code in my conf file. I am using AwesomeWM v3.5.9 (Mighty Ravendark) with Lua 5.3.3:

--From PROmpt COMmand:
procom = "rofi -show run"

awful.key({ modkey }, "r", function () awful.util.spawn(procom)

    for _,c in ipairs(client.get()) do
        if c:isvisible() then
            mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible 
        else 
            mywibox[mouse.screen].visible = mywibox[mouse.screen].visible 
        end
    end

end),

Restarting AwesomeWM won't complain at all, but my wibox won't disappear. If I change the code into something trivial (i.e. if mywibox[mouse.screen],visible as the conditional statement), the widgets will go away, but an empty black bar will stay there even if I quit Rofi, only returning to its initial state when summoning Rofi again (that is caused by the statement I initially made, that's why I considered as trivial).


Solution

  • The whole function in my rc.lua right now. Works fine, but I'm planning to improve it in the future. Answers the question perfectly, though.

     -- Prompt
        awful.key({ modkey }, "r", 
                  function ()
                      myscreen                 = awful.screen.focused()
                      commandPrompter          = "rofi -show run -normal-window"
                      blur                     = "hsetroot -fill /usr/local/share/awesome/themes/modded/back$
                      unblur                   = "hsetroot -fill /usr/local/share/awesome/themes/modded/back$
                      awful.spawn(commandPrompter)
                      myscreen.mywibox.visible = false
                      awful.spawn(blur)
                  end),
    

    enter image description here