I found eventually this post on a mailing list, Command line alternatives to x2goclient-cli, apparently from 2011:
If I've interpreted recent mail traffic (and roadmap in wiki)
correctly, x2goclient-cli is deprecated and will no longer be actively
develeoped. As far as I can see there currently are two alternatives
to using x2goclient-cli:
- x2goclient (the QT client) with command line options.
- pyhoca-cli.
I tried looking into the command line options of x2goclient
, and I cannot really figure out how to start a session using that ...
On the other hand, I found that pyhoca-cli
is in Ubuntu repositories:
... and I found a doc on its usage:
So, I've installed it with:
sudo apt install pyhoca-cli
... and following the instructions, I've tried this (since I've already made connections from x2goclient gui, I drop the --add-to-known-hosts
from the examples in the page); first one needs to "list desktops", that is, list desktop sessions (so you'd need to at least once establish a connection from X2Go client GUI)
$ pyhoca-cli --server 192.168.0.100 --list-desktops --user myuser
pyhoca-cli[139077] NOTICE: preparing requested X2Go session
...
Password:
pyhoca-cli[139077] (x2gocontrolsession-pylib) NOTICE: connecting to [192.168.0.100]:22
pyhoca-cli[139077] (PyHocaCLI) NOTICE: authentication has been successful
X2Go desktops available for sharing
===================================
Host: 192.168.0.100 - [192.168.0.100]:22
Username: myuser
myuser@:0
So, from above, I have the session myuser@:0
- and that is what I can connect to:
$ pyhoca-cli --server 192.168.0.100 --share-desktop myuser@:0 --user myuser --share-mode 1
pyhoca-cli[139324] NOTICE: preparing requested X2Go session
...
pyhoca-cli[139324] (PyHocaCLI) NOTICE: proceeding to interactive login for user ,,myuser''
Password:
pyhoca-cli[139324] (x2gocontrolsession-pylib) NOTICE: connecting to [192.168.0.100]:22
pyhoca-cli[139324] (PyHocaCLI) NOTICE: authentication has been successful
pyhoca-cli[139324] (x2gosession-pylib) NOTICE: Using session myuser-50-1639641479_stS1XSHADmyuserXSHADPP0_dp24 as master session for profile Pyhoca-Client_Session.
pyhoca-cli[139324] (PyHocaCLI) NOTICE: Press CTRL+C to end desktop sharing for this session...
^CKeyboardInterrupt
2021-12-16T07:58:35Z
pyhoca-cli[139324] (x2gosession-pylib) WARN: local folder sharing is disabled for this session profile
pyhoca-cli[139324] (x2gosession-pylib) WARN: local folder sharing is disabled for this session profile
pyhoca-cli[139324] (x2goterminalsession-pylib) NOTICE: cleaning up session myuser-50-1639641479_stS1XSHADmyuserXSHADPP0_dp24 after termination
pyhoca-cli[139324] (PyHocaCLI) NOTICE: X2Go session myuser-50-1639641479_stS1XSHADmyuserXSHADPP0_dp24 has been terminated
So, that works - note that:
- I've experienced that the
--share-desktop
command might fail to connect; in that case, I had to stop pyhoca-cli
; then start X2Go client in GUI mode, and connect once (succesfully) from there; then after that --share-desktop
started working again
- The
--share-desktop
command again opens a centered cutout as described in OP - which then requires scaled full-screen, and the scaling is retained once full-screen is exited
So, that is nice - now just need to figure out:
- How to enable/activate the X2Go server from the command line over ssh
- How to specify that I want a non-scaled "cutout" in full-screen mode, with automatic panning (via mouse pointer being moved towards top/bottom/right/left edges of the screen).
EDIT: Discovered the following: the above examples were done with (I think) X2GOClient GUI/Session Preferences/Session Type "X2Go/X11 Desktop Sharing". Motivated by Windows x2go client displays at incorrect resolution,
I tried to change Session Type to "MATE" (which is the desktop environment I use on both server and client, and shown in the screenshots above). With this, a window opens that is scaled to the max available size at the client's desktop resolution, and inside, I get the client desktop shown at accurate pixel size, starting from the top left edge (and the top bar is scaled to the size of this window) - and so I can run programs and see nicely what goes on.
What I cannot tell at the moment, is whether this is a copy of the desktop actually running - or is this a new session for the same user (probably new, pyhoca-cli --list-desktops --server 192.168.0.100
afterwards lists two sessions instead of one); at least, for some programs I use, that does not matter, so this solved the unreadable resolution for me (at least partially for now). Note also, that once you close the X2GoClient GUI connection - when you open the Session Preferences/Session Type next time, it (as said in linked post):
automatically changes to "Custom desktop" with command "MATE"
I guess, the equivalent for this on the command line is to create a new session:
pyhoca-cli --server 192.168.0.100 --username myuser --new --command MATE
... and once a new session is created, after you close the window (note that also if you hit CTRL+C on pyhoca-cli`, it will also close the window, and it does not delete the session, but instead suspends the session) and want to reconnect again, you do not need to create a new session again. First confirm there is a session existing with:
pyhoca-cli --username myuser --list-sessions --server 192.168.0.100
... or alternatively, list the desktops:
pyhoca-cli --username myuser --list-desktops --server 192.168.0.100
... and then you can resume a session instead (note a session name is required, not the desktop name; but session names OLDEST and NEWEST can be used as well):
pyhoca-cli --username myuser --server 192.168.0.100 --resume NEWEST
... or rather, you could, if there wasn't this bug #1445 - pyhoca-cli fails to connect to suspended x2go session - X2Go Bug report logs, which is apparently fixed in pyhoca-cli 0.6.1.3, however my Ubuntu 20.04 still has 0.6.1.2.
And, finally, to destroy/kill/erase a session, use --terminate
(which also accepts ALL):
pyhoca-cli --username myuser --server 192.168.0.100 --terminate ALL