I'm in the process of making a `x11vnc` launching script that would fix the dreaded black screen that prevents you from using VNC until reboot. So far, I've managed to find a workaround by using the newest `/run/sddm/*` file and changing `:0` to *n-1* of files in there accordingly. This is guesswork though and it will only work as long as the user switching only adds a display session to the end and then removes it. Once you try switching back using an item that is not the last, the problem returns because I have no way of telling which display is being used.
My progress so far:

```
#!/bin/sh

while true; do
lso=`ls -t /run/sddm/{* | grep -m1 -`
cnt=$((`ls /run/sddm/{* | grep -c -`-1))
/usr/bin/x11vnc -auth $lso -once -noxdamage -repeat -rfbauth /home/USER/.vnc/passwd -rfbport 5900 -shared -display :$cnt
usleep 400000
done

```

The highlight is that I got rid of the `-forever` and `-loop` to have it reload the server and supply it with fresh display config after every connection.

I need the current display, such as `:0` or `:1` to find the correct X cookie file (I can do that if I know the display number) and the correct output to have it show the proper monitor picture.

Running on Kubuntu 18.04 with all updates.