0

I'm trying to run my dotnet app from rc.local file. Where i start playing video(working) or show image slide show with feh player. If i run my scrip manually from bash is working how it' should.

When i try to run feh player i get:

feh ERROR: Can't open X display. It *is* running, yeah?

From rc.local

$(cd /home/pi/DigitalSignage/ ; sh startUpDigitalSignage.sh) &

startUpDigitalSignage.sh

#!/bin/bash
echo "Start Digital Signange"
sudo DISPLAY=:0 dotnet DigitalSignage.dll

I try to add DISPLAY=:0 before starting my app but no help.

From dotnet app i'm using Process call and i don't know how to add to call Display settings.

 process = new Process();
 process.StartInfo.FileName = "feh";
 process.StartInfo.UseShellExecute = false;
 string geometry = screenType == ScreenOutputType.HDMI_1 ? "1920x1080" : "1920x1080+1920";
 string textInfo = string.IsNullOrEmpty(outputText) ? "" : "--font  yudit/48 --info \"echo " + outputText + "\"";
 process.StartInfo.Arguments = " -Y -z "+ textInfo + " --geometry=" + geometry + " -x --zoom fill \"" + path + "\" ";
 process.StartInfo.RedirectStandardInput = true;
 process.StartInfo.RedirectStandardOutput = true;
 process.Start();
3
  • 1
    1. What version of Linux are you running? I'm asking because you write about a dll file, and that is a Windows file type; 2. If a 'typical' Linux distro with a graphical desktop environment (for example Ubuntu Desktop), you can start the process via 'autostart' (put a desktop file in the autostart directory), and you can be sure that the graphical session has started and can be used by feh. Commented Nov 3, 2021 at 7:57
  • I'm using dotnet extension on Raspberry Pi. Raspberry Pi reference 2019-07-10 Generated using pi-gen, github.com/RPi-Distro/pi-gen, 175dfb027ffabd4b8d5080097af0e51ed9a4a56c, stage4 Commented Nov 3, 2021 at 8:22
  • I have no direct experience of that Linux distro. But I suggest that you check, if it has the feature 'autostart', to start an application at login (and login can be automatic). Commented Nov 3, 2021 at 8:29

4 Answers 4

1

Remove the $ from the beginning of your command, because you do not want to execute the output from the command:

$(cd /home/pi/DigitalSignage/ ; sh startUpDigitalSignage.sh) &

Instead, just call your script and have that set up the environment correctly (DISPLAY, etc. For example,

In /etc/rc.local

/home/pi/DigitalSignage/startUpDigitalSignage

In your script startUpDigitalSignage

#!/bin/sh
# Start the digital signage
#
echo 'Start Digital Signage'

cd /home/pi/DigitalSignage &&
    DISPLAY=:0 dotnet DigitalSignage.dll &

Ensure it's executable:

chmod a+rx startUpDigitalSignage
0

I had the same issue with my feh script. I've solved it by adding export DISPLAY=:0 as the first command on my script.

I hope it helps you.

0

The problem in running GUI applications from rc.local or a similar start-up script is that things started that way are not intended to become a part of any GUI session at all. So you'll have to set DISPLAY and possibly adjust dependencies to make sure the script won't be executed before the GUI server has started up first.

You can avoid all that. There are specific places for things you wish to start as part of a GUI session start-up.

On Debian and related distributions (such as RasPi OS), you could add a script to /etc/X11/Xsession.d to have it executed every time a GUI session starts. It works even if you don't use a X display manager (= a GUI login dialog) or a GUI autologin, but use startx to start the GUI yourself after a text-mode login.

Other distributions might have done this differently, and have a separate place for things to execute on sessions started with a GUI login dialog vs. with startx. In that case, see the man page of your distribution's X display manager (usually man gdm, man sddm or man <whatever>dm) or your distribution's version of startx for the exact details.

Modern distributions also have the /etc/xdg/autostart/ directory: any desktop environment that complies with the respective XDG specification will start any application whose *.desktop file is placed into that directory. There is also a per-user version of this directory, usually at ~/.config/autostart/ (depending on how $XDG_CONFIG_HOME is set).

0

Try running feh without sudo and as a local user, that worked for me.

DISPLAY=:0 feh --geometry [3440]x[1440]+[0]+[0] -x png_pictures/

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.