Requirements:
- send different wallpapers to different monitors
- call from Go
- use
feh
underneath
muro and wallutils
wallutils
specifies a WM
interface that provides, among other things, the SetWallpaper
method. There are corresponding implementations of this interface for a number of different window managers.
The Go package muro
in turn uses wallutils
. Based on the flag WithAnyWindowManager
it will either use wallutils' SetWallpaperCustom
method which selects a concrete SetWallpaper
implementation based on the detected window manager or just directly call SetWallpaper
of the feh
variant.
wallutils and feh
The specific display mode depends on how it is called, but SetWallpaper
in wallutils feh.go would basically call feh
in your case as follows:
feh --bg-fill <image file name>
Two notes:
- here
feh
sets the wallpaper on all screens to the very same image
- therefore it's not directly supported to have different images
Also, wallutils' readme explicitly states:
Setting a wallpaper per monitor
Setting a wallpaper per monitor is not supported, yet. Currently, a wallpaper is set for all monitors.
see https://github.com/xyproto/wallutils#setting-a-wallpaper-per-monitor
Possible solution
Since you can determine monitors and resolution, we focus on sending the predefined images in the correct order as background images under use of feh
to the appropriate screens.
feh
itself supports setting different wallpapers per monitor. You just call feh
with the different images having different resolutions. The order is guaranteed to be the same as determined by a call to xrandr --listmonitors
.
After determining the order and taking it as a given, the simplest possible GO program would look something like this (see also wallutil's utility function run):
package main
import (
"os/exec"
)
func main() {
args := []string{"--bg-fill", "1.png", "2.png"}
cmd := exec.Command("feh", args...)
if _, err := cmd.CombinedOutput(); err != nil {
panic(err)
}
}
(tested with FluxBox
window manager)
Provided feh
works with the appropriate window manager and there are the two prepared images in the go directory, this is the simplest case. Of course, one could also programmatically determine the screens and dynamically adjust the call of feh
.
Since feh
does not work in every environment, wallutils provides concrete implementations of its WM
interface for a number of window manager environments (Cinnamon, Deepin, Gnome, Mate, Pekwm, Plasma, Sway, Weston, Xfce4). This is of course very cool. However, if you wanted to create an MR for wallutils, you would probably have to do so in all variants, at least those that support it.