Unfortunately, I forgot to start the emacs-server at work, running on Linux. Is there now any option to connect to my remote graphical X11 emacs session via ssh?
-
1What OS is running on the remote machine? If it is linux, is it running X? You might be able to use something like manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html to convince your emacs instance to do M-x server-start.– icarusFeb 1, 2017 at 3:26
-
@icarus: It is Debian Linux, X is running. Nice idea, although I thought there might be a more direct way.– pawel_winzigFeb 1, 2017 at 7:04
3 Answers
Since this is running on X, it might be possible to use a program like xdotool , xdo, or wmctrl
All these programs allow you to list windows, select one, and simulate typing on them.
Another approach would be to run x11vnc on the remote machine and connect to it with a local vnc viewer. The referenced manual page tells you how to forward needed ports using ssh.
Not answering the direct question, but I suggest the following in your init file to prevent this from happening in future.
;; Start server (but don't restart).
(require 'server)
(unless (server-running-p)
(server-start))
Alternatively (but still not helpful for your present situation), under the FUBAR: Impossible to connect heading on the "Emacs As Daemon" EmacsWiki page, there's an ingenious approach to enabling a server start to be triggered with a process signal.
If you have ssh
access to the respective server at work you can start the emacs server at work using the command (with the respective username and server host name):
$ ssh -X myuser@myserver.work.domain emacs --daemon
EDIT: If your emacs is already started on the server than just kill it and add automatic server start in your .emacs:
$ ssh myuser@myserver.work.domain killall emacs
$ ssh myuser@myserver.work.domain sh -c "echo '(server-start)' >> ~/.emacs"
Now you can start emacs in daemon mode as described on the first command. The added server-start command would enable the server on the opened emacs session.
-
-
It is not clear from the question. The question states "I forgot to start the emacs-server". Anyone using emacs-server on a regular basis has it started automatically when emacs is started. So stating that emacs-server was not started sounds like emacs itself is closed.– ElazarRFeb 2, 2017 at 19:19
-
-
* Down-voting my original answer (which was relevant for similar question of other users) is counter-productive...– ElazarRFeb 2, 2017 at 19:26
-
The question text "Is there now any option to connect to my remote emacs session" is pretty clear -- they have a remote emacs session, and they wish to connect to it. Killing the remote session helps (for this particular question) even less.– philsFeb 2, 2017 at 21:22