Bashscript plugin

Hi all,

I have Core & App running on a RPi with 7" screen and am having issues with the Bashscript launcher plugin - or the syntax.

I have a script to launch chromium-browser to a particular url.

The script is at /usr/local/bin/dash.sh - which has been marked executable.

I am able to launch the script fine - even from ssh shell via ‘dash.sh’ -which launches chromium on the screen as expected.

For the parameters of the bashscript plugin, I have been entering the full path of the script as above. It seems to accept this fine (wont accept within quotes, or just ‘dash.sh’)

Anyway, executing the script from nymea app does nothing…

Hoping I am missing something here, thanks in advanced

Jonny

Hi jonny21,

one issue could be the fact, that nymea is a daemon and will be started as root from the system. A root process starting a script will start the script as root too. Depending on the base system, this might cause an issue when starting GUI application.

Try to put su username into the script or try to make it work by starting the script as root.
You could try to run the command launcher instead of the script launcher with following command:

Note: replace user with your default user name of your system.

su -c /usr/local/bin/dash.sh - user

If this does not help, please past the script here and I’ll try to reproduce the behavior.

Cheers,
Simon

Thanks for you help Simon. I am still battling with it a bit… my script is
“/usr/local/bin/dash” containing:-

#!/bin/bash
DISPLAY=:0 chromium-browser http://proxybro:19999/mediadash.html
sleep 30
killall chromium-browser

My user is nymea

I have tried as you suggested, however no go with the application launcher method. I then added the 2 lines to my pam file as per here. Still no go unfortunately. I played around with adding su - user - c within the script without success.

Logging into the device via ssh (nymea@address), then simply launching /usr/local/bin/dash launches the script as expected over the touchscreen.

As to why this would be handy, I host some services on local servers here at home. Having this centrally mounted devices is cool to be able to control lights / garage gate and receive notifications about network devices… It would be great to walk past, hit the Dash button to quickly bring up my Netdata dashboard to check local device load. The dash looks really great when its up (launching manually from terminal).

If you have any other ideas, that would be great.

Cheers,

Jonny

Hey Jonny,

I have tried reproducing your setup and indeed, while it would work on my laptop (where nymead runs as my user) just fine, if nymead is started as a system service it would not work.

Now, sadly the command launcher plugin doesn’t print any error logs… (I’ll get that fixed, thanks for making me notice :slight_smile: ), however, I could get logs by modifying your script to this:

#!/bin/bash
echo Script started >> /tmp/dash.log
DISPLAY=:0 chromium-browser http://google.com >> /tmp/dash.log 2>&1

Now this would print all the output to /tmp/dash.log. First thing to notice, nymea’s environment might not have the PATH set, so use /usr/bin/chromium-browser instead. Also, running this through nymea now printed this log:

Script started
No protocol specified
/usr/bin/chromium-browser:  unable to open display ':0'

So, here we go, it fails to connect to the X server… Probably because root isn’t allowed to connect to your user server. So here’s what I did:

#!/bin/bash
echo Script started >> /tmp/dash.log
sudo -u nymea DISPLAY=:0 chromium-browser http://google.com >> /tmp/dash.log 2>&1

Et voilá, it works now.

Hope this helps you getting this sorted out.

1 Like

Hi Michael, thanks heaps for looking into this. My setup is based off your touchscreen guide :slight_smile:

You were right, the key was sudo -u nymea prefixing the command.

My complete script to open chrome to my dashboard / wait 30s / close chrome is:

#!/bin/bash
sudo -u nymea DISPLAY=:0 chromium-browser http://dash &
sleep 30
killall chromium-browser-v7

The parameters I used to launch the script via command launcher are:

sh /location/of/script

I may even use this method to launch the RTSP stream of a couple of ONVIF Surveillance IP Cams

Appreciate your help!

Jonny

Oh, you’re using an RPI with touchscreen stuff?

I’ll have some good news for you very soon, stay tuned :wink:

1 Like

Hey Jonny!

As promised, here’s the “good news”: New RPi image available for testing

Great, I’ll give it a run this weekend

Cheers