Open URL in Default Browser
Closed this issue · 2 comments
I'm using Kubuntu 19.10 and running mqtt-launcher.py as a systemd service on boot. I'm trying to get a URL to open in my default browser Chrome using xdg-open but I get the error "returned non-zero exit status 3". Here is my launcher.conf:
https://pastebin.com/raw/Wngw89fT
I have verified that xdg-open opens the URL fine as the user but errors as root with 'no method available for opening'. I have also tried running the systemd service as the user but get the same error.
I have also tried running mqtt-launcher.py in the user crontab to run on reboot but it does not launch.
Any ideas? Thanks.
Why are you running the launcher as root? I'm not familiar with the utilities you're using, but I'd think it unlikely that xdg-open would function when run out of the context of systemd, because it knows nothing about your display. Similarly, for the crontab experiment: this utility doesn't know about your graphical display.
If it's X11, you might get around by setting the DISPLAY
environment variable and xset +
on the display itself, but it's probably some new-fangled technology I'm not aware of.
That's about all I can do for you, unfortunately.
Thanks for the feedback.
I realized I was making this too complicated. I got the launcher to start on user login by adding a shell script with the following:
#!/bin/bash
/usr/bin/python /home/user/mqtt-launcher.py & &>/dev/null
to Autostart in the KDE Plasma 5 System Settings - and now I can get the URL to be opened when the topic/payload is received - since the xdg-open utility runs as the user and not root.
Thanks for the launcher script. It does exactly what I need !!