Cannot set background in sway

I haven’t been able to set my own background in Manjaro Sway. It always keeps the default background. I’ve got the image file at /usr/share/backgrounds/peakpx.png and I’ve made a file at ~/.config/sway/definitions.d/01-background.conf with this content:

set $background /usr/share/backgrounds/peakpx.png

but it’s not working.

Interestingly, in emacs there’s a command to set the currently viewed image as the desktop background and it just works™ (I don’t know what this does behind the scene to achieve this), however after logout and login it’s gone back to the default background.

Are you sourcing ~/.config/sway/definitions.d/* in your
~/.config/sway/config file?

ie:

include /home/<username>/.config/sway/definitions.d/*

I tried to test it in a VM
The VM performance was … terrible
likely because of wayland

set $background /usr/share/backgrounds/peakpx.png

I found that $background was not set …

I’ll not be pursuing this any further.

@merlock good thinking, but that’s not it. This line is in my ~/.config/sway/config file:

include $HOME/.config/sway/definitions.d/*.conf

running swaymsg 'output * bg $background fill' works to set the background to the image I want, so that shows that $background is being set correctly.

I’ve tried adding exec_always output * bg $background fill as the last line in ~/.config/sway/config and I’ve also tried adding swaymsg 'output * bg $background fill' to the end of .profile but neither works (after I log in then run source .profile manually the background gets set correctly)

perhaps .profile runs before the config files set the $background variable

Don’t set variables in .profile…

Correct command is:

output * bg $background fill

in your config file.

Note, no exec always or swaymsg

That didn’t work.

I’m considering putting a button on my waybar just to run the command that sets the background, but it seems crazy that I can’t figure out how to make it set automatically on login.

Did you try the way described in our SUPPORT.md?

I thought I had, but I never noticed the set $apply_background part. I must have been looking at outdated documentation. Adding that line to the config file makes it work.

Also I didn’t think that setting this variable would be necessary since it gets set to this exact value already in /etc/sway/autostart which is included in /etc/sway/definitions/ which itself is included in ~/.config/sway/config

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