Linux Companion App (LNX Link)


Custom Size – 1
This is a new tool that I created for controlling and monitoring a Linux OS. I’ve been using IOT Link on Windows and I wanted to have one for Linux, but I couldn’t find any alternatives. I’ve tested it on Ubuntu 20.04, but most likely it will work on most distributions.
Check my repo on github.

I’ve added most features of IOT Link, with an addition of a new feature for controlling and monitoring the media. I used this tool to create a media player on home assistant.

Hope you like it!


Awesome! Will try it out. I was using something I wrote as well. Just mqtt with a status and cmnd topic.

I use it to suspend my PC all the time. So it’s listening to dbus events, once it going to shutdown and sleep. It lets the broker know.

I didn’t think of checking the dbus events for shutdown and sleep.

The way I programmed mine is to consider the PC on when the app is running and sends off just before it’s stopped.
When the PC shuts down, it stops all running services gracefully, so my app will send the off command, though I haven’t tried it for sleep because I don’t use it.

I will give a try on your app, thanks for sharing!

Hi. I installed the app and it sends messages to my mqtt broker. However Home Assistant does not autodiscover it. Autodiscover is turned on and works perfect for IOT Link on my Windows pc. Any ideas?

I haven’t implemented Autodiscover yet on LNX Link.
You will have to add it manually through configuration.yaml.
I am planning to add this feature in the future.

Oohh. I see. I will do a manual configuration i HA then. Any ETA on autodiscovery?

I’ll try to add autodiscovery features it in the next weeks. I’ll let you know when I do.

1 Like

I’ve updated LNX Link to support MQTT AutoDiscovery.
Follow the installation instructions on github to update to the newest version.


This is awesome and I like idea very much, but how can I get currently played media info from any player?
As for now, I installed LNXLink on Archlinux machine and Ubuntu machine.

Archlinux: This is my main home server (media server, home assistant, cloud, mqtt, etc.) and this is also machine connected to main TV, where from we are watching movies from Stremio and VLC. This Achlinux machine is running with KDE.

  1. Only if I play some local media file in native KDE media player, i.e. Dragon Player, I have title, artist, status, playing info in LNXLink.

  1. If I play any media in any other player, I have no info in LNXLink (except for volume):


My main goal is to use LNXLink on this Archlinux machine for Stremio and VLC.
I know it is possible to obtain info from mentioned players (of course), cause KDE Connect app is displaying currently played media info, no matter what player is running.

Ubuntu: I installed LNXLink on some spare Ubuntu laptop just to check, cause I know that Archlinux knows to be troublesome for lot of things, but unfortunately, I don’t getting media info in LNXLink no matter what player is running. I tried everything I currently have installed on Ubuntu - Stremio, VLC, MPV and native Videos app.


Any help appreciated :slight_smile:

Thanks for getting in touch with me for this issue and for providing so much information.
I have some tips that might help you:

  1. My app supports multiple players, but find the 1st one to show information. I’ve made the assumption that that’s the that is playing. Try closing all other players, like chrome, vlc, etc… and just play with one at a time.
  2. Run my app manually to check for any error logs that might occur, but don’t forget to stop the service before doing so. This can be done like so: /usr/bin/python3 /opt/lnxlink/
  3. I am using Ubuntu Linux 20.04, so try running my app on that distribution to check if the problem still exists.
  4. To get the players, I am using a 3rd party library called mpris2. I have the link to the documentation. If you are not familiar with programming languages, let me know to create a simple script that we can get all the players to fix the problem.

Let me know if you could fix the problem or need more assistance.

@bkbilly : Thanks for reply!
I will be on some trip next few days starting from today, so will not be able to experimenting, but I will so as soon as I’m back home and will follow up.

Some comments for now:

  1. Will try, but on Ubuntu, this was already tried after fresh installation of LNXLink and right after fresh system boot up, but will see what logs have to tell (running app manually).
  2. Of course, this is always best idea. Running manually helped me to make it working as it is working now on Archlinux, cause Arch is totally different and didn’t worked at all out of box :slight_smile:
  3. I am also with 20.04 on mentioned Ubuntu laptop.
  4. I am usually able to make slight changes in code and fit it to my needs, but will ask for help if needed, thanks.

Hi. Unfortunately, I have no enough knowledge to fight with this :frowning:

Absolutely everything is apply the same for my Ubuntu and Archlinux. The only difference is that on Archlinux I have native KDE video player, called Dragon Player which is detected by LNXLink, but I’m not using it at all because it’s sucks :slight_smile:

Let’s first say: My deepest apologize for wrong data provided: my laptop isn’t on Ubuntu 20.04, but on 21.10 instead, sorry.

Second: In mean time, I noticed that media from web browser is detected successfully on both machines - Ubuntu 21.10 and Archlinux. E.g. no matter if I’m playing youtube or some other web video or music (soundcloud, etc.), media info is displayed on HA lovelace and this part with web borwsers is fully functional. Tested with Firefox, Chrome, Chromium, Konqueror and Tor (Ok, Tor is not giving media info, but LNXLink is giving info “Tor browser is playing media”)
(archmedia is Archlinux and DESKTOP-PC is Ubuntu):

I noticed that service starting very often has an errors. This is totally random and I’m restarting service until I get the start without errors. E.g. when I run systemctl --user start lnxlink , right after that I’m always running systemctl --user status lnxlink to check are there any errors. If there are errors, I’m doing systemctl --user restart lnxlink until I get clear status without errors (5-6 times sometimes).
Screenshot for better overview:

Error log for copy/paste:

Jan 11 16:33:34 archmedia python3[92666]: rc = self._packet_handle()
Jan 11 16:33:34 archmedia python3[92666]: File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 3039, in _packet_handle
Jan 11 16:33:34 archmedia python3[92666]: return self._handle_connack()
Jan 11 16:33:34 archmedia python3[92666]: File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 3138, in _handle_connack
Jan 11 16:33:34 archmedia python3[92666]: on_connect(
Jan 11 16:33:34 archmedia python3[92666]: File “/opt/lnxlink/”, line 85, in on_connect
Jan 11 16:33:34 archmedia python3[92666]: self.setup_discovery()
Jan 11 16:33:34 archmedia python3[92666]: File “/opt/lnxlink/”, line 135, in setup_discovery
Jan 11 16:33:34 archmedia python3[92666]: addon = self.Addons[service]
Jan 11 16:33:34 archmedia python3[92666]: KeyError: ‘network’

I also tried to add Environment=DISPLAY=:0 to lnxlink.service file, cause it was complain that cannot find display specified, result is the same with or without - no media info from VLC and Stremio.

If I stop service and run program manually with cd /opt/lnxlink && /usr/bin/pyhton3 /opt/lnxlink/ , sometimes I got following on Archlinux:

[[email protected] bin]$ cd /opt/lnxlink/
[[email protected] lnxlink]$ /usr/bin/python3 /opt/lnxlink/
Connected with result code 0
cpu sensor
memory sensor
Exception in thread Thread-1 (_thread_main):
Traceback (most recent call last):
File “/usr/lib/python3.10/”, line 1009, in _bootstrap_inner
File “/usr/lib/python3.10/”, line 946, in run
self._target(*self._args, **self._kwargs)
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 3591, in _thread_main
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 1756, in loop_forever
rc = self._loop(timeout)
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 1164, in _loop
rc = self.loop_read()
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 1556, in loop_read
rc = self._packet_read()
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 2439, in _packet_read
rc = self._packet_handle()
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 3039, in _packet_handle
return self._handle_connack()
File “/usr/lib/python3.10/site-packages/paho/mqtt/”, line 3138, in _handle_connack
File “/opt/lnxlink/”, line 85, in on_connect
File “/opt/lnxlink/”, line 135, in setup_discovery
addon = self.Addons[service]
KeyError: ‘network’

And some other time, everything is ok:

[[email protected] ~]$ cd /opt/lnxlink/
[[email protected] lnxlink]$ /usr/bin/python3 /opt/lnxlink/
Connected with result code 0
cpu sensor
memory sensor
network sensor
media sensor

Same apply if I’m running /usr/bin/python3 /opt/lnxlink/ or DISPLAY=:0 /usr/bin/python3 /opt/lnxlink/

Unfortunately, I don’t know to debug it further. I checked MPRIS2 page, but only thing my knowledge letting me do is to check running players from python console. It’s detecting VLC, but I have no VLC media info in HA.


Regarding Stremio, it is not related with your app. It seems that Stremio cannot be detected via mpris2:


I believe this post is confusing, sorry for that.

Addition, just discovered, what a heck: If I’m playing corrupted media file in VLC, the one which will never start and VLC player would become stuck with orange line sliding left-right in VLC progress bar, then info is there in lovelace, LOL.


These are some left overs after my last HDD crashing, it seems I still didn’t cleaned up all garbage. Sorry, with any other media file, correct and working media file, there is no info from VLC :frowning:

Really strange, just keep an eye on archmedia lovelace card :slight_smile:
Big Hero 6 is corrupted media file, and TMNT is valid media file.

I also can see that if I load .mp3 files to VLC, I’m getting proper media info in home assistant. Was I maybe on wrong track from beginning and is this way possible to get an info only from audio media files and not from video :slight_smile: ?

One more edit: Anyway, getting info in home assistant when playing .mp3 file, but there is also no info when playing .m4a audio file in VLC :frowning: Firstly I meant it could be some problem with metadata inside media file container, but don’t think so cause “playing” is also not changing from false to true with .m4a and video files (.mkv, .mp4) and it’s changing with .mp3

I am not sure what is the problem with the KeyError ‘network’ that you get, but I will keep that in mind.
Could you check that the file /opt/lnxlink/modules/ and that the network option on config.yaml exists like the template?

As for your original question you should try running this small app and send me the output.
It will check all running players and try to get their status and the metadata.
The player that the LNX-Link app is using is the 1st one. If it’s any other, then you can help me look for a way to find which status should I check to get the results.

Ok, so, I found where is the problem.

All my previous posts in this thread should be ignored. I’d rather strike-through all of them, but it’s probably stupid.

It seems this thing is heavy relying on metadata from media file. If there is no metadata on main media container, then will not be media info from player. Even “playing” will be “false” and “status” will be “idle”.


As said post before, I noticed that some of my .mp3 files are giving media info in Home Assistant, so I analyzed them with FFMpeg. It gives me below output:

Opposite to my video files, which weren’t giving info in Home Assistant:

After I added metadata on main container with:

ffmpeg -i Brave.2012.1080p.BRrip.x264.stiw47.Dual.mkv -c copy -metadata title="Brave" -metadata language="Serbian // English" -metadata artist="Pixar" -metadata album="Brave" Brave.New.Metadata.mp4

I got following:

And media info in Home Assistant finally appeared:


And FYI, just one metadata parameter, e.g. title, would be enough for get info. I will see is there any GUI software which can quickly set metadata on bulk of files according file name or something similar, or will give up of this, cause I have around 1k media files :slight_smile:
Also will check could maybe some VLC settings be tweaked, cause as said before, Dragon Player is giving proper info in Home Assistant with same media files, ones without metadata.

Thank you for your answer.

I have file: /opt/lnxlink/modules/ , below is file content:

[[email protected] ~]$ cat /opt/lnxlink/modules/
import psutil
from datetime import datetime

class Addon():
    service = 'network'
    name = 'Network'
    icon = 'mdi:access-point-network'
    unit = 'Mbit/s'

    def __init__(self):
        self.timeOld =
        self.sentOld = psutil.net_io_counters().bytes_sent
        self.recvOld = psutil.net_io_counters().bytes_recv

    def getInfo(self):
        """ Returns Mbps"""
        timeNew =
        sentNew = psutil.net_io_counters().bytes_sent
        recvNew = psutil.net_io_counters().bytes_recv

        timeDiff = (timeNew - self.timeOld).total_seconds()
        sentDiff = sentNew - self.sentOld
        recvDiff = recvNew - self.recvOld

        self.timeOld = timeNew
        self.sentOld = sentNew
        self.recvOld = recvNew

        sentsSpeed = round(sentDiff * 8 / timeDiff / 1024 / 1024, 2)
        recvSpeed = round(recvDiff * 8 / timeDiff / 1024 / 1024, 2)

        return {'download': recvSpeed, 'upload': sentsSpeed}
[[email protected] ~]$

I’m not sure how to work with templates yet (and what is the template in this case :slight_smile: ), but below is content of config.yaml

[[email protected] ~]$ cat /opt/lnxlink/config.yaml
  prefix: iotlink/archmedia
  clientId: archmedia
  statsPrefix: archmedia-monitor/stats
  port: 1883
    enabled: true
    enabled: true
    qos: 1
    retain: true
    connectMsg: 'ON'
    disconnectMsg: 'OFF'
- shutdown
- send-keys
- run
- notify
- media
- cpu
- memory
- network
- media
[[email protected] ~]$

I tried this small app, below is output. Currently, only VLC is playing, my kids are watching cartoon, one without metadata :slight_smile:

[[email protected] ~]$ python /opt/lnxlink/
1) st=Playing, title=None, artist=None, album=None
[[email protected] ~]$

I can see that is giving proper info, cause status is really playing and this file have no metadata, but “status” in Home Assistant card is “idle” and “playing” is “false” as said before :frowning:

Certain case for VLC, maybe this could be hint:

If I’m playing .mkv file with barely metadata within, title=“tmnt test”, output from would be:

[[email protected] ~]$ python /opt/lnxlink/
1) st=Playing, title=tmnt test, artist=None, album=None
[[email protected] ~]$

It will be shown in HA, all together with “status”: “playing” and “playing”: “true”:


And I would be able to see same that “tmnt test” in VLC player as title:

From other side, if I’m playing same that video file, but this time without metadata at all, would be:

[[email protected] ~]$ python /opt/lnxlink/
1) st=Playing, title=None, artist=None, album=None
[[email protected] ~]$

It will not be shown in HA, “status” and “playing” will be wrong:


But, in VLC player, file name will be shown as title, in lack of real metadata title:

Maybe you could use this somehow.

Please don’t take me wrong, my intention is not to pushing. I just noticed this and would like to let you know. Everything here is based on free will and only if you have a time and if you want to take a look.

I am really happy that you took an interest to find the bugs on my app, so I don’t feel pushed.

The problem with getting the current media that it’s playing is that I am heavily relying on the mpris2 library so that I can have it as global as possible. I’ve noticed some problems if there are more than one players at the same time. This needs some fine tuning, but I don’t think that this is what is wrong in your case. I will push an update once I get the chance.

I am not sure how to use the vlc player metadata as an alternative, so I am not sure that I could help you with that…

I will push an update in the next days for the bug with the multiple players which might help you.