Periodically checks a Minecraft server for changes in online players, logs those changes, and sends desktop notifications (using libnotify) for those changes.
The following setup assumes python-gobject
(Python 3) is installed by your package manager.
This dependency can be satisified by pip install PyGObject
from within the venv, but compile
issues might occur (and is outside the scope of this article).
python3 -m venv ~/.venv/mc/ --system-site-packages source ~/.venv/mc/bin/activate pip install mcstatus
Update the address
in the main()
function to point to the server you want to monitor.
You need to execute this script with the Python from the venv you created, e.g.:
~/.venv/mc/python watch_mc.py
The script will keep running until terminated by Ctrl-C or some other means. You may want to use a terminal multiplexer to keep it running long term (or just & it if you don’t care about output).
tmux new -n mc_watch -d 'cd ~/script/directory; ~/.venv/mc/bin/python watch_mc.py'