So I neglected to save a file on my home pc before leaving.
Then at work I wanted to continue editing the same file.
My home desktop was not configured for VNC so what to do?
I investiagted attaching a vnc server to a running desktop, without access to that desktop but quickly came to the conclusion that it would just be a massive security flaw and hence not allowed.
I was just about to give up when I remembered dbus
With an ssh session open I was able to tell the instance of kate running on the home pc to save the file without ever seeing the desktop.
And it's actually really easy!
First you need to get the right display - for 99% of cases that will be display 0
export DISPLAY=:0
now you need to find the running instance of kate
qdbus | grep kate
hopefully there is only one
Now identify the correct document
(N.B. replace the number below with the once found from the previous statement)
qdbus org.kde.kate-28399 | grep Document
If there is only one document open then its easy, otherwise you need to go through each document and see if its the right one.
Unfortunatly there doesn't appear to be a way to get the filename, so you'll have to inspect the content
qdbus org.kde.kate-28399 /Kate/Document/1 org.kde.KTextEditor.Document.text
Repeat this for all the documents until you find the one you want then issue:
qdbus org.kde.kate-28399 /Kate/Document/13 org.kde.KTextEditor.Document.save
If you get the response
true
then the document is now saved!
I did investigate whether this same method could be used to attach a vnc server using krfb but (thankfully) it can't
This method almost certainly can be adapted to other applications and editors though - as long as they support dbus