Search code examples
luacustomizationdesktopwindow-managersawesome-wm

AwesomeWM shows loading icon when changing wallpaper from rc.lua


I am trying to do something similar to a Compiz effect I liked a lot in Reddit. I have tweaked my rc.lua in a way that, when Super+R is pressed, every client gets hidden, the wallpaper changes to a blurred one (stored in another directory) and Rofi spawns:

So now I can go from here:

enter image description here

To here:

enter image description here

HOW TO REPRODUCE:

The code I used for this is the following:

wallpaper.sh: this script allows me to change my wallpaper from the command line. It also creates a blurred version of the wallpaper in order to be used every time I call Rofi.

#!/bin/bash

if [[ $1 != "" ]] && [ -f $1 ]; then
    cp $1 /usr/local/share/awesome/themes/modded/background.png
    convert $1 -blur 0x6 /usr/local/share/awesome/themes/modded/background-blurred.png
    feh --bg-fill $1
else
    echo 'Invalid file!'
fi

rc.lua function: this function deals with the keystroke "Mod4+R", hiding all clients, blurring the wallpaper and spawning Rofi:

  awful.key({ modkey }, "r", 
          function ()
              myscreen           = awful.screen.focused()
              commandPrompter    = "rofi -show run -normal-window"    
              blur               = "feh --bg-scale /usr/local/share/awesome/themes/modded/background-blurred.png"
              unblur             = "feh --bg-fill /usr/local/share/awesome/themes/modded/background.png"

              for _, t in ipairs(mouse.screen.tags) do 
                  if client.name ~= "rofi" then
                      awful.tag.viewtoggle(t) 
                  end
              end
                     
              myscreen.mywibox.visible = false
              awful.spawn(commandPrompter)        
              awful.spawn(blur) -- Causes mouse to change to loading icon!!                  
          end),

rc.lua function 2: this function is located at the very end of my rc.lua file and activates whenever a client called "rofi" closes (throws an unmanage signal). The function will make everything return to normal, unblurring the wallpaper and toggling the clients and the wibox.

--Makes the wibar appear when Rofi exits.
client.connect_signal("unmanage", function(c)
     myscreen = awful.screen.focused()
       if c.class == "Rofi" then
                     for _, t in ipairs(mouse.screen.tags) do 
                                awful.tag.viewtoggle(t) 
                     end
                     awful.spawn(unblur)        -- Causes mouse to change to loading icon!!
                         myscreen.mywibox.visible = true                  
       end
end)

Pressing Mod4+R will cause the problem to appear.

enter image description here

Important detail: Strangely, Gnome Screenshot won't show the 'loading' pointer, converting it to the regular arrow one. I had to take a picture from my phone in order to show the real pointer to you. Sorry!


Solution

  • You need to add false as the second parameter of awful.spawn. This disable the protocol commands are supposed to implement to notify the window manager they are done initializing.