Score:0

How to kill x2go client when connection is lost?

np flag

I use x2go client on an Ubuntu laptop to work on a remote Ubuntu server. My network connection is not very stable (WiFi), and it disconnects several times per day. When this happens while I'm using x2go, the laptop basically becomes unresponsive for a few minutes, until x2go client shows a dialog asking if it shall disconnect.

The x2go client runs in full-screen mode. There are keyboard shortcuts to disconnect or minimize the client, and also a mouse "shortcut" (CTRL-click in the upper right corner), but they stop working when there is no connection, so there is no easy way to close x2go.

The only way I found so far is to switch to a text terminal with CTRL-ALT-F3, log in with a password, kill the x2go client from command line, then log out and switch back to the GUI session with CTRL-ALT-F1, log in with a password again. Both options (wait for a few minutes or switch to a text terminal) are pretty inconvenient, so I'm looking for any kind of a better solution.

Some solutions I was thinking about, but don't know how to make them work:

  1. Write a bash script which detects when x2go client gets disconnected and kills it in a few seconds. Unclear if it's possible to detect a disconnection in a reliable way.

  2. Some kind of a special system keyboard shortcut to run a script which kills x2go client. Standard Ubuntu desktop shortcuts don't work while x2go is in full-screen mode.

  3. Any way to make x2go client handle a minimize or disconnect shortcut on the client side?

Score:0
it flag

You can use my net-o-matic script to do this. net-o-matic monitors the state of the WiFi connection. When the connection goes DOWN, net-o-matic does a user-specified "thing". I've used it to restart WiFi, try the next WiFi network, etc.

https://github.com/waltinator/net-o-matic

Easily configured, well written bash (IMHO), comes with examples.

Anton K. avatar
np flag
Thanks. I now have a more reliable internet connection, so didn't come to test the script in real use. But reviewed it, learned a few things. One little issue: the script uses `ip link show` to check connection, and this may give a wrong result when I have a wired connection via a modem (laptop - wire - modem - TV cable). When the modem is restarted, it takes ~2 minutes to actually connect to the internet, but `ip link show` shows a connection immediately (though that's not WiFi). I think a simple solution for this case may be ping, e.g. `ping -c 3 -w 10 google.com`.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.