In this article I will tell how you can keep the mcabber jabber client on a remote server constantly running and use it to connect to the server via ssh. Also here will be described how you can implement notifications of incoming messages.
The profits from this scheme are as follows:
- you are constantly on-line
- if the connection suddenly breaks, you do not have to re-login and lose (if unsuccessful) offline messages
- logs are stored in one place and accessible from anywhere where there is internet
- you can use mcabber from any device that supports ssh, whether it is a mobile or a web client
- say that ssh eats less traffic than xmpp (did not check)
The disadvantages include:
- server need
- interface slowdown (on slow channels)
- the need to use a console client (for someone it's even a plus)
Starting and using mcabber on a remote server is easy. In principle, there is almost no difference compared to the setting locally.
For experiments, you can use the
blinkenshell.org service, which provides free shell accounts for sitting on their irc channel. However, to become a full-fledged user there you have to spend a couple of days, and the server’s response is not the best for them. The article is written on the example of settings for the blinkenshell server, but you can easily apply it to your own.
To run mcabber on the server, you can use the following command:
tmux new-session -d -s mcabber mcabber
(tmux is an analogue of screen, in my subjective opinion it is better)
On the local computer, then it will be enough to execute in the terminal:
ssh -t blinkenshell 'LANG=ru_RU.UTF-8 tmux attach -d -t mcabber'
where -d means that any other tmux mcabber session must first be detailed. Thus, it is achieved that mcabber will be connected only from one computer. blinkenshell is an alias configured in ~ / .ssh / config.
')
If you followed
this guide, then you can set awesome in the config file:
awful.key({ modkey }, "grave", function () scratch.drop("urxvtc -e ssh -t blinkenshell 'LANG=ru_RU.UTF-8 tmux attach -d -t mcabber'", bottom, center, 0.98, 0.95) end),
and thus reduce the launch of the client jabber on the computer to the key combination Win + `, after which the terminal opens with an ssh session in which mcabber will already be running.
It becomes more interesting when we want to be notified of events on a remote mcabber.
In mcabberrc on the server, write the following lines:
set events_command = ~/.mcabber/event.sh
The contents of ~ / .mcabber / event.sh is small:
#!/bin/sh
echo $@ >> logfile
With this we create a logfile on the server, into which all mcabber events will be added.
For notifications, I used
a python
script written by the mcabber developer. Included is a clear configuration file and readme. The script and configuration file should be placed in the ~ / .mcabber / directory on the local computer.
Then in the same place we create a remote_events.sh script with the following content:
#!/bin/zsh
SERVER=blinkenshell
EVSCRIPT=~/.mcabber/mcevent.py
CONFFILE=~/.mcabber/mcevent.cfg
ssh $SERVER 'tail -n0 -F ~/.mcabber/logfile' < /dev/null | $EVSCRIPT -c $CONFFILE &|
It connects via ssh to a remote server and reads the contents of ~ / .mcabber / logfile. When launched, the script will respond only to the last mcabber event (-n0 key). And then it will constantly monitor changes in this file (-F key) and transmit new events to the notification script.
That's all. Now you can start the computer by simply launching remote_events.sh, connect via ssh to the server where mcabber is waiting for you and work with it as if it were running locally.
PS I would love to hear suggestions for optimizing this scheme.