Fixing wallpapers to screens with Nitrogen on i3 (Is there a CLI for Nitrogen?)

I've got a big TV screen that I like to hook up to my computer on certain occasions; however, my idea could also be applied to holding presentations with an external screen. I'd like to show a special wallpaper on the new screen, which should come up automatically after changing the screen layout with the arandr-generated command.

I've managed to get this to work temporarily by relying on Nitrogen restoring the last layout, however, this is quite unreliable. The two screens I always have connected are, in the default layout, recognized as Screen 1 and Screen 2. When switching to the TV-Layout, Screen 2 suddenly becomes Screen 3, with the TV taking its place as Screen 2.
This must confuse Nitrogen, because when switching to the TV-Layout, the TV screen (Screen 2 after the switch) "duplicates" the wallpaper from my regular screen (Formerly Screen 2, afterwards Screen 3). On the other hand, switching back to the Default layout after having set the Wallpapers as I'd like them, my default Screen 2 takes the wallpaper of the TV screen.

Given the above, I'm not sure I can find a way to rely on Nitrogen restoring the wallpapers automatically. As a workaround, I'd like to put commands that correctly set up the wallpapers into both of my arandr-generated screenlayout scripts. However, command-line options for Nitrogen only seem to help start the GUI, and I couldn't find out which backend is used to set the wallpapers.
What options do I have here?

Have you tried using feh? It allows to assign backgrounds to displays in a certain order. You'd only have to edit the ~/.fehbg batch and execute when needed.


Thanks for the tip! I've installed feh and read up on the man pages. I'll just document my steps here for later reference.

The command structure to achieve my goal is:

feh <fill-directive> img0...imgn

where <fill-directive> is one of

  • --bg-center
  • --bg-fill
  • --bg-max
  • --bg-scale
  • --bg-tile

and img0...imgn are the images to be used for screens 0 through n.

I put the resulting commands into the shell scripts that can be saved by arandr into ~/.screenlayout so I can just execute them when I want to switch. Additionally, I pasted the content of my Default layout script into /etc/lightdm/Xsession/ (before the last exec command) for global effect even after reboot.

1 Like

You may produce the batch file with my azote. On X11 it uses feh. Just set desired wallpapers: azote saves your settings to ~/.fehbg. Available in AUR.

For instance:

feh --no-fehbg --bg-scale '/home/piotr/.azote/backgrounds-feh/part0-wallhaven-4g738q.jpg' '/home/piotr/.azote/backgrounds-feh/part1-wallhaven-4g738q.jpg' 
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by