swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.55k stars 1.11k forks source link

Different wallpapers for different workspaces #6267

Open sujay1844 opened 3 years ago

sujay1844 commented 3 years ago

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!!

emersion commented 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.

vyivel commented 3 years ago

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).

JanczarKurek commented 2 years ago

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?

gergo-salyi commented 1 year ago

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

baleksa commented 1 year ago

There is a solution to the flickering problem here: https://sylvaindurand.org/dynamic-wallpapers-with-sway/