sway icon indicating copy to clipboard operation
sway copied to clipboard

Different wallpapers for different workspaces

Open sujay1844 opened this issue 4 years ago • 3 comments
trafficstars

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

sujay1844 avatar May 10 '21 06:05 sujay1844

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.

emersion avatar May 10 '21 07:05 emersion

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

vyivel avatar May 12 '21 14:05 vyivel

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?

JanczarKurek avatar Jul 24 '22 16:07 JanczarKurek

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

gergo-salyi avatar Apr 08 '23 17:04 gergo-salyi

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

baleksa avatar May 29 '23 17:05 baleksa