Open sujay1844 opened 3 years ago
This would require swaybg to listen to Sway IPC events. I think this should be implemented in a third-party background program, not in swaybg. swaybg is designed to be simple.
A proof of concept:
#!/bin/sh
swaymsg -r -t subscribe -m '["workspace"]' | \
jq -rc --unbuffered 'select(.change == "focus") | .current | "\(.name) \(.output)"' | \
while read name output; do kill $!; swaybg -i "$name.png" -o "$output" & done
The running directory must have wallpapers named after workspaces (i.e. if you have workspaces "1", "2" etc, then you must have files 1.png, 2.png etc).
There is a problem with external solution tho, namely It is noticably slow, especially with 4k wallpapers visible delay between change of workspace and a change of wallpaper. Anybody achieved smooth experience using external scripts?
I just made an third-party tool in Rust for this: https://github.com/gergo-salyi/multibg-sway It combines an event loop from a Rust-native implemented wayland wlr layer shell client and a sway ipc client. The wallpaper switching on workspace change works pretty fast this way, there is 1 frame of lag only. Anyone finding this feel free to use it / reuse the design of it
There is a solution to the flickering problem here: https://sylvaindurand.org/dynamic-wallpapers-with-sway/
Can you guys make a feature where each different workspace can have a different wallpaper?? This can be useful. I can intuitively know in which workspace I am rather than looking at a tiny number on the top left (usually) of the screen. I'm not sure if any major window manager has this feature. And I'd love for sway to be the first!!