0

I have following idea:

I have a wallpaper in 2 version. One original and second a bit blurry. I want to change the wallpaper from original when first window/program opens on the screen. Once the last window/program is closed change the wallpaper back. Also when I change between tags I want to check if any window/program is open or not and then adjust the wallpaper.

How can I do that?

P.S. I use nitrogen to set wallpaper

AwesomeWM client created/removed callback

n1_
  • 4,227
  • 4
  • 34
  • 35

1 Answers1

0

I found a way to set the wallpaper depending on the visible clients, but I have no idea how your Nitrogen calls look like. Just replace the naughty.notify lines with your Nitrogen invocations.

Somewhere in your rc.lua, you should find something like this:

awful.screen.connect_for_each_screen(function(s)

Add the following to that function

tag.connect_signal("property::selected", function(t)
  if #s.clients > 0 then
    naughty.notify({text = "set blurry wallpaper", timeout = 1})
  else
    naughty.notify({text = "set original wallpaper", timeout = 1})
  end
end
)

table.getn is deprecated but this is the solution for older lua versions:

tag.connect_signal("property::selected", function(t)
  if table.getn(s.clients) > 0 then
    naughty.notify({text = "set blurry wallpaper", timeout = 1})
  else
    naughty.notify({text = "set original wallpaper", timeout = 1})
  end
end
)
ploth
  • 435
  • 8
  • 16
  • Thank you. I'm getting error tho: "attempt to call a nil value (field 'getn')". Also how about the "open first/close last" window callback? – n1_ Oct 26 '18 at 06:55
  • Oh you are right. `table.getn` is deprecated. I've updated my answer. – ploth Oct 26 '18 at 07:12
  • Thank you. I'm working on the final solution. Just a small question. Where did u get the "s" variable in the function and what exactly the "#" does? – n1_ Oct 27 '18 at 08:32
  • `s` is the current screen when looping over all your screens ([here](https://awesomewm.org/doc/api/classes/screen.html#awful.screen.connect_for_each_screen) is the documentation). `#` is lua code, it's returning the number of array elements. – ploth Oct 28 '18 at 21:02