A way would be to follow this article which gives an idea of how it works. To make a socket communication and send the command as stated in the article, a daemon would be recommended. For more information on daemon - read this. An example on how to program a daemon can be found in the samples MyDaemonSwing on github.
For the python part of the daemon, have a look at this post.
1 Like