This script emulates having Virtual Desktops enabled only on named displays. On all other displays, the windows will be shown on all desktops, effectively emulatating not having any Virtual Desktops for these displays.
If all you need is to enable Virtual Desktops ONLY on primary monitor, and don't want to configure anything, I recommend simply using Virtual Desktops Only On Primary
For many other use cases, this script will let you enable Virtual Desktops on more than one monitor, regardless of which monitor is primary.
Configuration is very simple. Just add a comma separated list of displays that should be enabled for Virtual Desktops.
If you don't know the name of the display(s) you want to enable for Virtual Desktops, just look in System Settings. The names of all connected displays are shown as follows:
In the above example, the four displayes are named HDMI-0, DP-1, DVI-D-0 and DVI-I-1.
If you do not see a button for configuration options, try the following:
mkdir -p ~/.local/share/kservices5
ln -fs ~/.local/share/kwin/scripts/selective-virtual-desktops/metadata.desktop ~/.local/share/kservices5/selective-virtual-desktops.desktop