Welcome to ZaiNaLe Developer Community-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

chromium - Shell script works properly when manually launched, but "fails" when launched by a service

I am trying to set up a digital display board using a Raspberry Pi 4 running the latest release of Rasbian Version 10(buster). The script needs to launch 2 chromium browser windows in kiosk mode, and set each window to it's own monitor. With the way my code is now if I manually launch the shell script from bash, it works and does what it is supposed to. But, I need to to be launched with a service so the display comes up after a power outage. When the .sh script is launched by the service the widows both open, but are loaded onto a single monitor. This is all a fresh install, so the versions of unclutter and sed would be the latest release as of Jan 11,2021.

The code:

communitydisplay.sh

#!/bin/bash
xset s noblank
xset s off
xset -dpms

unclutter -root &

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/chromium/Default/Preferences

/usr/bin/chromium-browser --new-window --no-first-run --incognito --noerrdialogs --disable-infobars --kiosk <web page link> --window-position=0,0 --user-data-dir="Monitor1" &
/usr/bin/chromium-browser --new-window --no-first-run --incognito --noerrdialogs --disable-infobars --kiosk <second web page link> --window-position=1920,0 --user-data-dir='Monitor2'

communitydisplay.service:

[Unit]
Description=Community Display launcher
Requires=graphical.target
After=graphical.target

[Service]
Environment=DISPLAY=:0.0
Environment=XAUTHORITY=/home/pi/.Xauthority
Type=simple
ExecStart=/home/pi/communitydisplay.sh
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=graphical.target

I have tried setting up separate services for each window, as I think the "Environment=DISPLAY=:0.0" is what is causing the issue. However I have yet to find the correct combination of words to put into google to find what the Raspberry Pi 4 labels the second monitor as. I have tried :1.0 and :0.1 assuming it is an array index.

running "w" in terminal I get the output:

USER    TTY    FROM    [email protected]    IDLE    JCPU    PCPU WHAT
pi      tty7   :0      Mon12     22:13m  51.41s  1.95s /usr/bin/lxsession -s LXDE-pi -e LXDE
pi      tty1   -       Mon12     22:12m  0.13s   -bash

I have also sifted through journalctl, but can't find any error code(s) related to my service or script.

I have read through the "Similar Questions" suggested, but none have the solution I am looking for.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to ZaiNaLe Developer Community-Open, Learning and Share
...