If I am understanding the operation of set-wallpaper correctly, you rely on the existance of /usr/bin/gsettings as the indicator of the choice of gnome as the desktop environment. In fact, it only indicates that gnome has been installed on the computer, which is often true even if another desktop is in use.
A better test would be against something like $XDG_CURRENT_DESKTOP, which would resolve the desktop actually in use.
Will work on a PR that works for KDE....