I can restart my desktop from a console window (Ctrl+Alt+F1) with this command:
sudo service lightdm restart
This will present a fresh login screen and closes all programs running on the desktop. This it not what I want.
I want a command or a script that restarts the desktop from a console while keeping all applications running, so I can access their windows when I get back the desktop screen.
I keep having problems with the desktop blacking out while the computer remains running fine. There are 9,286 posts with "black screen" with different causes. Some with solutions like this, some without. I am working with many Xubuntu computers and had it happen multiple times.
While causes differ, (in my cases) the symptom is often the same. It usually helped to restart lightdm, but I was losing my data and had to restart all applications. Now I had the problem when testing VGA matrix switches. Every time I reconnected my monitor, I had to reset lightdm. So I learned that what I need is a better workaround. Something analogous to restarting explorer.exe with the Windows Task Manager. This solves every hang up of the desktop but does not affect running programs (it basically restarts the desktop).
System: Xubuntu 16.04 64-bit, PC laptop